STM32F030 Microsecond delay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-11-16 5:10 AM
Hi every body, how can I create a microsecond delay in STM32f0? ( this MCU has not DWT register)
Thank you
- Labels:
-
STM32F0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-11-16 5:21 AM
Use any other free-running TIM to delta progress of time.
​
Clock a 1 MHz or faster to improve resolution. Don't interrupt. Remember most TIM here will be limited to 16-bit.​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-11-16 5:34 AM
Thank you, could you please tell me the details or give me an example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-11-16 6:12 AM
I've posted examples and discussed this before. It really shouldn't be that complex to think through..
Set the TIM up in Timebase mode, set the Period as maximal, ie 0xFFFF
Set the Prescaler as MHz-1, ie 31 if the bus clocks at 32 MHz, the tick time should be 1us
void delay_us(uint16_t us)
{
uint16_t start = TIM2->CNT;
while((TIM2->CNT - start) < us); // rebase, then compare
}
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-11-16 7:25 AM
Thank You, Please check my CubeMx config, is it correct?
my HCLK = 48Mhz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-11-16 11:07 AM
Looks reasonable, not using CubeMX here. Likely some timebase examples under the HAL CubeF0 trees also
Up vote any posts that you find helpful, it shows what's working..
