Timer precision on at91rm9200

Joel Sherrill joel.sherrill at oarcorp.com
Tue Oct 30 14:49:49 UTC 2007


Rochat Joël wrote:
> Hello,
>
> I'm working now on the rtems timers. I use an at91rm9200 with th csb337 bsp.
> I generate an 1khz timer on a pio pin and i measur with an oscilloscop the
> result of it. And I have a little difference with the expected value .
>
> I measure 1,0012 ms but I shoud have 1.0 ms. 1 khz is not very high
> frequency, I think it could be more precis.
>
>   
Just to make sure you understand.  The Classic API timers
just schedule functions to be called inside the context of the
clock tick ISR.  So what we are talking about here it that the
clock driver's is not dead on the money for 1 ms.

See c/src/lib/libcpu/arm/at91rm9200/clock/clock.c
and see if you can fix it.

It may be the math for the "counts per tick" or
Clock_driver_support_at_tick() not taking into
account the length of time between the counter
going to 0 and the ISR doing whatever it has to
do to make the next tick occur.

But remember .. the clock tick ISR happens, then
rtems_clock_tick is called, then your timer handler.
If I read this correctly, you have a reasonably square
wave that is just not 1ms in length. 
> I'v modified the bsp.h for my board :
> #define BSP_MAIN_FREQ 20000000      /* 3.6864 MHz */
> #define BSP_SLCK_FREQ   32768      /* 32.768 KHz */
>
> I know that the bsp for csb337 was configurer with an 184 Mhz mck. My board
> have an 180 Mhz mck. I didn't find where I could modifie it.
>
> Here is a part of my code :
>
> //definition 
> #define CONFIGURE_MICROSECONDS_PER_TICK 100
>
> //timer declaration
> status = rtems_timer_create (rtems_build_name( 'T', 'A', '1', ' ' ), &timerId);
> status = rtems_timer_fire_after(timerId, 10, timer1kHz, NULL);
>
> //function called by the timer
> rtems_timer_service_routine timer1kHz (rtems_id timer_id,void *user_data)
> {
> 	if (gTick == TRUE)
> 	{
> 		*AT91C_PIOD_SODR = AT91C_PIO_PD1 ;
> 		gTick = FALSE ;
> 	}
> 	else
> 	{
> 		*AT91C_PIOD_CODR = AT91C_PIO_PD1 ;
> 		gTick = TRUE ;
> 	}
>
>
> 	rtems_timer_reset(timer_id) ;
> }
>
>
> I hop you can help me.
>
> Have a nice day
>
> Joel
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>   




More information about the users mailing list