This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to delay microsecond using BIOS?

Hello:

I need a microsecond delay function that using the BIOS kernel APIs.

How do setup to have microsecond delay using BIOS API?

Thank You

Mike

 

/**************************************************************************************************
 * @fn          BSP_Delay
 *
 * @brief       Delay for the requested amount of time.
 *
 * @param       # of microseconds to delay.
 *
 * @return      none
 **************************************************************************************************
 */
void BSP_Delay(uint16_t usec)
{   
 
}

  • Hi Mike,

    what device are you using, at what CPU frequency, and in what context are you using this function?

    BIOS doesn't implement such a function explicitly...but I would look into using the SYS/BIOS' Timer module. For example, the Timer module could allow you to call a tickFxn after the us period has expired. The period would be specified using Timer_setPeriodMicroSecs(). It be be worth mentioning that at a us rate, you probably would want to just poll on the delta t's of Timer_getCount()'s  or using the Timestamp module's Timestamp_get32() return values. If us is extremely low, then perhaps you want to loop on CPU cycles...

    In either case, it should probably spin on some variable instead of trying to perform a BIOS call that would cause the calling Task to block. By spinning on a variable,  you can also use this function within a Hwi/Swi.

  • Hi Tom:

    Thank you for your responsed.

    The BSP_Delay(...) function is small delay and the caller must get block execution for few microseconds max. It is very short delay so the other CPUs / RF communication must be sync order to play nicely with other.

    I am trying to search in TI forum for the Timer_getCount(..) and Timestamp_get32(..) examples that shows me how to implement a BIOS delay.

    Do you have delay function hanging around for me to study?

    Mike

  • Hi Mike,

    I don't have any explicit code examples that delay at the us level. What device are you using? You need a timer that runs at a high enough rate that can give you us increments, in particular if you want to use Timestamps.

    You could use the Timestamp module to determine its frequency rate to scale the Timestamp_get32() counts to us. Then in your delay function, you could use Timestamp_get32() to get the current count value and just spin in a while loop until the Timestamp_get32()'s return value has incremented x number of counts that correspond to the desired number of us.