cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_Delay_Microseconds on STM32F302R8

Joe Sanford
Associate
Posted on June 19, 2018 at 19:27

I'm trying to find a way to use a delay of 300microseconds in my code.  

I'm currently using a F302R8.  

I'd like to do this without using interrupts for the time being, if possible.  

Is there a HAL_Delay_Microseconds available for the F302? I know that the 'delay_hal.h' library is available on some chips (STM32F4x) ... but not sure how to verify the best way to do this with the F302.  

I'm not tied to using the HAL functions ...  

I'm trying to do something like this:  

HAL_GPIO_TogglePin(GPIOA, sonarTxPin_Pin)

HAL_Delay_Microseconds(300);

Thank you.

#hal_delay #delay_microseconds #nucleo-f302 #delay-1us
1 REPLY 1

Figure that it is impractical to interrupt at 1 MHz, what rational people do is take a free running counter at 1 MHz, or faster to give fine granularity, and then loop until the delta ticks between when you entered and now describe the time span desired. Some STM32 have 32-bit counts, others 16-bit ones, this will constrain total dwell time. All of the CM3, CM4 and CM7 parts have a DWT_CYCCNT which is a 32-bit counter ticking at CPU rate. At 72 MHz 32-bit covers around a minute.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..