Microseconds sleep with Leon2

Manuel manuel.coutinho at edisoft.pt
Thu Nov 20 09:39:20 UTC 2008


Hi

>From my (limited :)) experience I think that you are demanding too much from
your hardware. If I understood correctly, you are using the Leon2 hardware
timer to generate interrupts every 50 us. Supposing that your ISR takes
about 10 us to execute (which I think is an conservative estimate), 20% of
your CPU usage is spent here :S. Furthermore, waking up other threads (with
the semaphore release) takes even more time...

Remember that an ISR takes some time to execute. 

I would advice, if possible, to call directly the functions you need to
perform INSIDE the timer2 interrupt routine. Perhaps this is not easy or not
even possible :S. Since you use semaphores, I suppose you need some mutual
exclusion algorithms. This could only be achieved by disabling interrupts in
that region (with this approach). Of course, if your operations take a long
time to execute...your timer2 accuracy will suffer since interrupts are
disabled for a long time :S.

This is a though problem and it's hard to suggest a better solution without
understanding more of the system :S

Nevertheless, hope this helped...at least a bit :)
Manuel Coutinho

> -----Original Message-----
> From: rtems-users-bounces at rtems.org [mailto:rtems-users-bounces at rtems.org]
> On Behalf Of Arquer Stephane
> Sent: Thursday, November 20, 2008 9:03 AM
> To: rtems-users at rtems.com
> Subject: Microseconds sleep with Leon2
> 
> Hi,
> 
> I try to make a specific function to wake up tasks after some hundreds of
> µ seconds.
> I use the timer 2 of a Leon2 with a resolution set to 50µs , but I obtain
> a rough result with 200µs more than the request time.
> Does anybody have an idea ?
> 
> I can't load the timer with a value less than 50, a lower value block the
> execution.
> Is it possible to manage an ISR every 10µs ?
> 
> I work with rtems 4.8.0 with the patch 4.8.1diff, and a Leon2.
> 
> 
> Thanks for help.
> 
> sa
> 
> 
> 
> 
> /*****/
> rtems_isr handleTimer2(rtems_vector_number vector)
> {
> 	int i;
> 	TIMER2_TICKS ++;
> 
> 	if (Nbre_Timer_Actifs > 0){
> 		for (i=0; i < MAX_TIMER; i++)
> 		{
> 			if (TAB_Timer[i].actif) {
> 				if (TAB_Timer[i].decompte > 0) {
> 					TAB_Timer[i].decompte--;
> 				} else {
> 
> 	rtems_semaphore_release(TAB_Timer[i].sem_id);
> 					TAB_Timer[i].actif = FALSE;
> 				}
> 			} /*if*/
> 		} /*for*/
> 	}/*if*/
> } /*handleTimer2*/
> 
> 
> 
> 
> 
> 
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users




More information about the users mailing list