2018-06-19 10:27 AM
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-1us2018-08-09 08:00 PM
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.