2018-12-25 09:40 PM
2018-12-26 05: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.
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.
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
2018-12-26 04: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.
2018-12-26 04: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.
2018-12-26 04:49 AM
BTW, what do you need nanosecond range timings for?
2018-12-26 05: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.
2018-12-26 09: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.