cancel
Showing results for 
Search instead for 
Did you mean: 

ST USB_LIBS 3.2.0

stefanofante9
Associate II
Posted on June 23, 2010 at 10:56

ST USB_LIBS 3.2.0

4 REPLIES 4
chikos332
Associate II
Posted on May 17, 2011 at 13:55

Personally I agree the use of systick instead of ''bare count'' because the old method depends strongly on CPU speed and load and could be very variable. Besides, it is a blocking process (other tasks are blocked when delay is running) while systick can be used with interrupt.

Since you use the Systick for your application, you can combine both functionalities using local/global variables (tokens).

Or you can modify the uDelay function to use a Timer instead of systick.

stefanofante9
Associate II
Posted on May 17, 2011 at 13:55

the use of a interrupt delay is not so simple.... almost all the function used in the usb stack are called from OTG irq.

The SYSTICK timer is used for istance in the FreeRTOS realtime kernel

for the contest switch... and this timer is the obvious one to use for this scope.

 

trevor23
Associate III
Posted on May 17, 2011 at 13:55

If you already have a ms tick count maintained by systick then why not use this for the delay e.g.

void delay_ms(u32 delay_ms)

{

   u32 start = systick_ms;

   while ((systick_ms - start) < delay_ms)

   {

      .

      // maybe do other stuff here

     .

   }

}

sytick_ms needs to be volatile.
stefanofante9
Associate II
Posted on May 17, 2011 at 13:55

I already have a function like the one you suggest me,

I use this function in my code!

The problem to use this delay function in USB stack is that the USB functions are called from inside the USB IRQ HANDLER!

There is a nesting irq problem to solve in order to use a interrupt driven delay.

I have a couple of Real Time OS that  use the SYSTICK as system tick source....

I criticize the use of SYSTICK in this way because you loose a timer for

a delay function!