[ECOS] Drift in Real Time Clock

M Arshad Khan marshadkhan@gmail.com
Tue Jun 5 04:59:00 GMT 2007


Hello
we r running eCos on simple intel based PC. we want to find the drift
in the real time colck, for this we simply capture a 100Sec signal
using 20mSec interrupt. the signal was captured using a counter by
triggering the channel of the counter using parallel port of the PC.
the code is given below.
from the results we found that  the drift was 7mili Sec in 100 Sec.
This drift is very large to fitt for real time colck. we also tried
this code on different PC's but app same results. can any body tell me
why i am getting so much drift...
any suggestions..



#include <pkgconf/system.h>     /* which packages are enabled/disabled */
#ifdef CYGPKG_KERNEL
# include <pkgconf/kernel.h>
#endif
#ifdef CYGPKG_LIBC
# include <pkgconf/libc.h>
#endif
#ifdef CYGPKG_IO_SERIAL
# include <pkgconf/io_serial.h>
#endif

#ifndef CYGFUN_KERNEL_API_C
# error Kernel API must be enabled to build this example
#endif
/* INCLUDES */

#include <stdio.h>                      /* printf */
#include <string.h>                     /* strlen */
#include <cyg/kernel/kapi.h>            /* All the kernel specific stuff */
#include <cyg/io/io.h>                  /* I/O functions */
#include <cyg/hal/hal_arch.h>           /* CYGNUM_HAL_STACK_SIZE_TYPICAL */

#include <cyg/hal/hal_io.h>		/* HAL input and output */

cyg_uint8 val;

cyg_handle_t counter_hdl;
cyg_handle_t sys_clk;
cyg_handle_t alarm_hdl;
cyg_alarm_t alarm_handler;
cyg_alarm alarm_obj;

unsigned long iindex;
unsigned long ccount=0;
//
// Main starting point for the application.
//

void cyg_user_start( void )
{
	HAL_WRITE_UINT8(0x378,0x00);
        sys_clk = cyg_real_time_clock();

        cyg_clock_to_counter( sys_clk,&counter_hdl );

        cyg_alarm_create(
counter_hdl,alarm_handler,(cyg_addrword_t)&iindex,&alarm_hdl,&alarm_obj
);

        cyg_alarm_initialize( alarm_hdl,cyg_current_time() + 200,2 );



}

//
// Alarm handler.
//

void alarm_handler(cyg_handle_t alarm_handle, cyg_addrword_t data )
{
	if(ccount==0)
	{
		    	HAL_WRITE_UINT8(0x378,0x01);	      	
	}
		
	if(ccount==(100*50))
	{
		    	HAL_WRITE_UINT8(0x378,0x02);	      	
	}
	ccount++;
}

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list