Is there any possibilities to produce nanosecond delay from STM32F4 Discovery ?
because using HAL_Delay can only produce 1ms delay which is 500KHz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-12-25 9:40 PM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-12-26 5:18 AM
Your Discovery board seems to have F407 on it, and you can run it with 168 MHz -> 6ns clock.
The closest you can get is 33 tick period = 5.05 MHz and 17 tick duty = 102 ns using a timer on APB2.
Timers 9, 10 and 11 are good candidates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-12-25 10:39 PM
You mean 1ms delay between toggling gives you 500kHz?
I don't think you can get nanosecond delays in any way. A single instruction takes a couple - depending on your HCLK frequency. Is microsecond enough? Although I don't think HAL gives you those either. But you can set up a timer to give you that (= making your own clock).
Note that period of 180MHz is 5.56 ns.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-12-25 11:34 PM
aaah i see, if iam set up timer for myself, how do i do that ?,
actually i want to produce 5MHz frequency as shown as above
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-12-26 4:42 AM
You can't expect interrupts at such a rate bit you can use a high speed free running timer to observe the passage of time. For signal generation consider using a TIM to manage the pin directly. ​
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
‎2018-12-26 4:47 AM
You want that kind of signal to show on a pin?
Then you need at least general purpose timer.
The easiest way is probably put that timer in a PWM mode with period of the frequency and duty cycle of the pulse width. That way the timer generats the signal without processor (except for setting it up).
Basically PWM mode is a kind of output compare mode, but easier to use.
And as a plus, you can change the pulse width on the fly by writing a new count value to the compare-register.
Note, however, that if it works well, depends on the chip you use - its frequency. Typically, with STM32s, the maximum count frequency of the timers is the HCLK., and that also gives the accuracy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-12-26 4:49 AM
BTW, what do you need nanosecond range timings for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-12-26 5:18 AM
Your Discovery board seems to have F407 on it, and you can run it with 168 MHz -> 6ns clock.
The closest you can get is 33 tick period = 5.05 MHz and 17 tick duty = 102 ns using a timer on APB2.
Timers 9, 10 and 11 are good candidates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-12-26 9:50 PM
oh thank you very much, i will try it, so i have to manipulate te TIM function to produce the nanosecond timer
at first i need nanosecond delay because of with 200ns delay it equal with 5MHz, so i think if i can produce 200ns delay i already got what i want.
this 5MHz i will apply it in Ultrasound Tranducer.
