public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "M Arshad Khan" <marshadkhan@gmail.com>
To: ecos-discuss@ecos.sourceware.org, ecos-discuss@sources.redhat.com
Subject: [ECOS] Drift in Real Time Clock
Date: Tue, 05 Jun 2007 04:59:00 -0000	[thread overview]
Message-ID: <4690b0d10706042159k40c3e12cp7e92a4a4cb66d2b0@mail.gmail.com> (raw)

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

WARNING: multiple messages have this Message-ID
From: "M Arshad Khan" <marshadkhan@gmail.com>
To: ecos-discuss@ecos.sourceware.org, ecos-discuss@sources.redhat.com
Subject: [ECOS] Drift in Real Time Clock
Date: Tue, 05 Jun 2007 12:31:00 -0000	[thread overview]
Message-ID: <4690b0d10706042159k40c3e12cp7e92a4a4cb66d2b0@mail.gmail.com> (raw)
Message-ID: <20070605123100.J25Ttu_hFk41fmiEt2PvQHZ2pjl5otP-2cQmJinEGcg@z> (raw)

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

             reply	other threads:[~2007-06-05  4:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-05  4:59 M Arshad Khan [this message]
2007-06-05 12:31 ` M Arshad Khan
2007-06-05 17:49 ` Andrew Lunn
2007-06-05 18:31   ` Andrew Lunn
2007-06-06 10:33   ` M Arshad Khan
2007-06-06 10:37     ` M Arshad Khan
2007-06-06 12:20     ` Nick Garnett
2007-06-06 14:29       ` Nick Garnett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4690b0d10706042159k40c3e12cp7e92a4a4cb66d2b0@mail.gmail.com \
    --to=marshadkhan@gmail.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).