it helped me a lot, i really thank you for sharing this video
@uguraltunbilek2 жыл бұрын
nice video .Thank you so much for this valuable information
@jayasharma42084 жыл бұрын
Thank you sir, your videos are very helpful!, Can I implement same procedure for getting microsecond delay in nucleo STM8S?
@ControllersTech4 жыл бұрын
Yeah the same logic can be applied for any microcontroller
@iforce2d4 жыл бұрын
Thankyou, very helpful.
@youssefsallak3339 Жыл бұрын
I have a question how can I calculate a very short pulse between 1nanoseconds this is to calculate the speed of light and thanks
@devjeetmandal14725 жыл бұрын
First of all thanks for this easy and useful tutorial. I wanted to clarify few things and i hope you can give me some answers for it. Suppose my mcu is running at 180MHz and my timer1 is at 90MHz, then how are you determining the lowest possible delay in ns? As you said your controller can generate only at least of 10ns delay, i wanted to know how you came to that conclusion that it can generate only at least of 10ns? What are the required calculations needed so by choosing any mcu of any clock speed i can determine the lowest possible delay i can generate.? Regards
@ControllersTech5 жыл бұрын
See, let's consider that the timer 1 is running at 100 MHz. That means one cycle would take (1/100Mhz) = 10ns. That's how it is calculated. Also if your timer is running at 90 Mhz, than one cycle would take (1/90MHz) = 11 ns. If you want to create a delay of 1ns, your timer should have a frequency of (1/10^-9) = 1000 MHz. That's not possible for now.
@devjeetmandal14725 жыл бұрын
@@ControllersTech To run my timer in 100MHz how are you calculating the values for prescale and arr regsiter.??.
@MrHause134 жыл бұрын
@@devjeetmandal1472 I don't undarstand your question. You said that your timer1 is at 90MHz. So you can't get 10ns, because u need at least 100MHz clock. You set clock for timer as you want because it is possible in stm32. So for example you take the highest speed (why not) what is 90MHz in your case. So you know that it's not impossible to get 10ns delay. So go for the next one which is 100ns. All what you need is to set cycle to 10MHz, because it give you 100ns. So set your prescaler as (9-1). 90MHz/9=9MHz. And arr register the highest possible value. You don't really use the arr register because you don't use interrupt after counting to the set value. Timer is just counting to set value, then after reach top value it is set to 0. Other way is to set clock for this timer to 10MHz then prescaler to (1-1). The arr register is use to set length (to which numer your timer count) with defined frequency.
@TheOldProgramming4 жыл бұрын
Hi thanks for the tutorial! If my max clock speed is 80mhz can i divide it 800-1 and get a timer which counts 10microseconds? Then can i have an interrupt that triggers when the timer reaches 10microseconds after its activation? This is needed for me to be able to read hc-sr04 sensor without active waiting with a while loop? Would it work? EDIT: What will be the counter value? Thanks in advance :)
@ControllersTech4 жыл бұрын
Yeah that would work. You need the periodic delay. Also prescalar doesn't depends on hclk clock. You need to check the APB timer clock od the timer that you are using. In case apb is 80MHz than prescalar can be 800 and counter 0. This would create a delay of 10 MHz
@TheOldProgramming4 жыл бұрын
@@ControllersTech Hi thanks for the answer! I am trying to measure the time for distance measure using the timer(set at 1us) and an interrupt(set on rising and falling edge) on the echo pin of the hc-sr04 sensor to read everything in non blocking mode. Basically i use the same timer for triggring the sensor and then when the interrupt rises i just restart the timer and each time the timer counts i check if the echo pin goes low and if so i stop and compute the distance using the time counted. But this is not working D: I have to read 4 hc-sr04 sensors. If i use direct input mode on 4 channels of the same timer can i measure the time from each these 4 channels concurrently? Would this work?
@ControllersTech4 жыл бұрын
i don't understand the point of using the interrupt. It's just 10us, and the entire processing doesn't take much time. you can still run other functions
@yohannsalliege19742 жыл бұрын
Hi I have the same nucleo F446RE but didn't manage to get 10 ns, the minimum I can get with delay (1) is around 530 ns, it acts like there is a limit
@مغربي_راسي_عالي4581Ай бұрын
The maxmium frequency of your Microcontroller may be less than 100 MHz that's why i guess
@sangtruong8833 Жыл бұрын
at 6.33, the screen shows pulse width about 0.1 nano second, is right?
@jayasharma42084 жыл бұрын
I am using stm32f0 board, and maximum hclk frequency is 48MHZ , how to generate delay of microsecond????
@ControllersTech4 жыл бұрын
Watch the video properly. It depends on APB clock, where the timer is connected.
@vinithkumar59642 ай бұрын
In this video he is explaining something and in reference page , its completely different clock setting. which one to follow
@ControllersTech2 ай бұрын
The clock settings depends on your mcu. How to configure it is explained in both, the video and on the reference page as well.
@JoaoNelsonLima3 жыл бұрын
Great job guy
@maso5532 жыл бұрын
Hi Controllers tech, what is the name of the device being used an an Oscilloscope in the video?
@ControllersTech2 жыл бұрын
DSO138
@The2Coolest23 жыл бұрын
My delay function is suddenly not working and I do not know why. It's been working for months. For example, a 10uS delay is producing a 17uS delay instead on the oscilloscope. I did not change anything.
@ControllersTech3 жыл бұрын
Well you should change everything based on your controller..
@The2Coolest23 жыл бұрын
@@ControllersTech I meant I did not change anything over the months I used it.
@ControllersTech3 жыл бұрын
There must have been some changes.. you need to recheck every detail i guess..
@ganeshgaikwad21585 жыл бұрын
Hello sir.. please guide me for conncting compact flash card to stm32f373 ....
@paulg.30674 жыл бұрын
Is this your own voice? If not, what speech synthesis are you using?
@ControllersTech4 жыл бұрын
I use amazon polly. Neural engine
@nielshib6352 жыл бұрын
Clock is 80Mhz and pre scalar is set to 80. What is the maximum us delay that can be achieved using this function?
@ControllersTech2 жыл бұрын
65535 us (16 bit counter, so max = 0xffff)
@malekmahar3 жыл бұрын
Hi, I followed every step you did, including HAL_TIM_Base_Start and the code doesn't run, it gets blocked in the delay_us function
@ControllersTech3 жыл бұрын
What delay value are u using ?
@saikrishnakaruturi2958 Жыл бұрын
Is it possible sir, after the update event is occured on timer2 in timer synchronisation is it possible to add delay for that timer2. Please give me your reply?
@ControllersTech Жыл бұрын
I think you are looking for dead time. Google it, there are some examples on it. I haven't covered it yet
@saikrishnakaruturi2958 Жыл бұрын
@@ControllersTech no sir not the dead time I want to give some delay after the update event is occurred. So that what I want to do to get some delay after the update event is occurred
@DIY_Repair20244 жыл бұрын
Thank you very much for this method. But it can't works, cause you not startet TIM Base generation. For correct starting must write HAL_TIM_Base_Start(&htim1); before while(1) loop. Either your TIM Base Generation startet somewhere automatically - it is HAL man :))))
@ControllersTech4 жыл бұрын
The code does have HAL tim base start. I guess i forgot to mention it. I will put it in the description..
@willleemaipipi4 жыл бұрын
Why d not just use Hal_delay() function? any difference betrween?
@ControllersTech4 жыл бұрын
Hal delay provides minimum delay of 1 millisecond. This video shows how to create delays in microsecond
@해헤-u9e3 жыл бұрын
thanks to help.
@sujoybhattacharya99384 жыл бұрын
This is not able to give me 10ns delay in stm32h743zi2?
@WhyAndWhatIf-Questions4 жыл бұрын
Firstly, thanks to your video. But I tried a lot with stm32f446re nucleo and the LED doesn't blink. I have even used usb logic analyzer and still got nothing...
@ControllersTech4 жыл бұрын
Did u start the timer in the main function.. Hal_Tim_base_start
@WhyAndWhatIf-Questions4 жыл бұрын
@@ControllersTech I mean, I did the same as you but the delay is not same. I used Nucleo STM32F446RE with APB2 is 100 MHz, Prescaler 1-1, AutoReload Register is 0xffff-1 and delay function with delay parameter is 10000 but the result is not 10ns.
@ControllersTech4 жыл бұрын
Can u telegram me @controllerstech
@mohamedazharudeen64774 жыл бұрын
what is the settings for creating milli seconds delay using this fucntion
@ControllersTech4 жыл бұрын
You just have to divide the clock such that the final timer clock will be of 1000 hz. So each count in ARR will take 1 millisecond
@yunusemreyagan49464 жыл бұрын
Hello controllers Tech. Can i add dead time to PWM signals generated in Timer 3 channels on stm32f407 discovery board?
@ControllersTech4 жыл бұрын
Dead time ?
@yunusemreyagan49464 жыл бұрын
@@ControllersTech yes
@design46823 жыл бұрын
@@emre_iris can you share the code regarding this?
@SadiqAli-qp3kl2 жыл бұрын
Can you guide for 100ns delay, with 48mhz clock....using stm32f07
@ControllersTech2 жыл бұрын
Just follow the video. It explains the process
@SadiqAli-qp3kl2 жыл бұрын
@@ControllersTech I tried but its just limiting to 1 micros sec.
@ControllersTech2 жыл бұрын
Use a better mcu with higher speed
@kobalov14 жыл бұрын
my timer just doesnt start :( it stays at while loop forever. I rly don't understand why it doesnt work I have set up everything in config and have exact same code. Maybe my ADC1 analog read is somehow messing with the timer ? or my definition of outputs idk
@ControllersTech4 жыл бұрын
If u want to test the timer, run the timer alone. Don't use any adc code. Just blink the led after some delay Make sure that you have started time using hal tim base start function
@kobalov14 жыл бұрын
@@ControllersTech I don't see the command to start timer in your timer tutorial but thank you very much I added it and followed temperature one wire sensor code and after some trying I got it working :) it's reading the temperature and my analog read from potentiometer is also working!!! Thank you so much :D !!!!
@johnsaeid954 жыл бұрын
hello what if have 80MHZ for timer then I need trigger 48000 in one second Is that doable ?
@ControllersTech4 жыл бұрын
You want 48000 times high (freq 96000), or both high and low (freq 48000) ?
@ControllersTech4 жыл бұрын
In either case u can use the prescalar value = TIM CLK / Required frequency. Keeping the ARR at max
@johnsaeid954 жыл бұрын
No I want 48khz (the timer occurs 48khz ) The reason for the question is that I guess 48khz can't be achieved exactly there will be always 10 or 20 above or lower 48khz , Am I right ??
@ControllersTech4 жыл бұрын
In that case, better use the APB timer clock as 48 KHz. And prescalar as 0
@johnsaeid954 жыл бұрын
@@ControllersTech how is this possible I need to keep my sysCLK 80MHZ anyway I sent you an email on admin@controllerstech.com
@polatozcanlar26004 жыл бұрын
100 000 000/(1*65536)=1525.87 Hz How does it works on 100 mhz? Am I wrong?
@ControllersTech4 жыл бұрын
I thing you didn't understood it properly we entered the prescalar as 100, so the timer clock is 100/100 = 1 MHz Each count in the ARR takes 1 us yeah the ARR is 65536, but we are not counting upto TOP of the counter. just count as many microseconds delay you need.
@polatozcanlar26004 жыл бұрын
@@ControllersTech TY for answer but in 2:23 isnt it prescalar? İts 1 or i am blind?
@ControllersTech4 жыл бұрын
that's for the nanosecond delay. prescalar 1 means the timer clock would be at 100 MHz, and each count will take 10ns.
@binodanio2199 Жыл бұрын
where is the prescalar as 100, i see only prescalar as 1-1 i 2:23@@ControllersTech
@ControllersTech Жыл бұрын
@binodanio2199 prescaler of 100 is not used in the video. But if you want the delay in us, with the APB timer clock of 100MHz you need to set the prescaler 100.
@ramalingeswararaobhavaraju58134 жыл бұрын
Thank.
@exaltedcodiing66553 жыл бұрын
I have exactly do what you have done, but my programme is not giving any delay. prescaler=0 arr=0xffff-1 APB2=100Mhz
@ControllersTech3 жыл бұрын
In the main function, call the timer start Hal_tim_start(handler)
@exaltedcodiing66553 жыл бұрын
the frequency or time do not match the delay timming
@ControllersTech3 жыл бұрын
U can contact on discord or telegram
@exaltedcodiing66553 жыл бұрын
@@ControllersTech i am there,
@RixtronixLAB4 жыл бұрын
How can I get 20 seconds timer3 interrupt ? cheers
@ControllersTech4 жыл бұрын
Just divide the timer 3 prescalar such that the timer frequency is 1000 hz. That means the timer will take 1ms for each count. Now set the ARR as 20000 to have a delay of 20 sec. Make sure you enable the update event interrupt
Make sure you enable the update event interrupt What should I update?
@ControllersTech4 жыл бұрын
But this will give you the delay of 8 sec max..
@RixtronixLAB4 жыл бұрын
@@ControllersTech How can I make it more? TIM_TimeBaseStructure.TIM_ClockDivision = 1;?
@devjeetmandal14725 жыл бұрын
I tried to create 10ns delay but it doesn't work... I have set prescale to 0 and arr register to 18. And it gives me 1us delay. My controller is stm32f44zet6 nucleo
@ControllersTech5 жыл бұрын
What's the timer frequency ?
@devjeetmandal14725 жыл бұрын
APB2 TIMER CLOCKS :180MHz
@ControllersTech5 жыл бұрын
First bring ur timer frequency to 100MHz, than set the prescalar to 0 and ARR to 0xffff-1
@devjeetmandal14725 жыл бұрын
@@ControllersTech yeah it was a mistake i kept timer1 at 180MHz now i have changed it to 100MHz. But somehow i am getting rise time 20ns and fall time 30ns. Period is around 1.18us and frequency is 847.4 KHz
@ControllersTech5 жыл бұрын
I need to see the code. Telegram me @controllerstech
@andrey75304 жыл бұрын
Ths man!!!
@innomus91094 жыл бұрын
Is this code blocking mode?
@ControllersTech4 жыл бұрын
Yes
@innomus91094 жыл бұрын
@@ControllersTech Hi thanks for the reply. Any suggestions how I can have the same delays but in none blocking mode?
@ControllersTech4 жыл бұрын
Use timer interrupt if the delay is large. Interrupt is pointless in smaller delays
@juhigullu4 жыл бұрын
my hclk is showing max 84hz when i try to change it to 180 it is not changing ...showing 84hz max ..what to do? then what to put the value at apb2? i am using stm32f401re
@ControllersTech4 жыл бұрын
The max clock in F401RE is 84MHz. You can't run it higher than that. I use f446re, that have 180 MHz. How much is APB2 clock ?
@juhigullu4 жыл бұрын
@@ControllersTech 84
@juhigullu4 жыл бұрын
so how to put modifications?
@ControllersTech4 жыл бұрын
Put prescalar as 84-1 and ARR as 0xffff-1
@gharibissam70334 жыл бұрын
Awesome work ! Thank you so much. micro-seconds works fine with me but I still have problem with ns delay, it doesn't work... I have set prescale and arr register to many possibilities. And it gives me always a delay value > 1us . My controller is STM32F413ZH nucleo. I can send you my code. Many thanks for your help
@ControllersTech4 жыл бұрын
What's the max HCLK possible for your controller ? To create delay of 1ns, timer frequency must be 1GHz For 10ns -> 100 MHz For 100ns -> 10 MHz.
@gharibissam70334 жыл бұрын
Thank you for fast responding. Actually it's 100 MHz and I need a delay of 50 ns for my application. Do you like that I send you my code via your email admin@controllerstech.com ? Thank you so much
@ControllersTech4 жыл бұрын
Yeah sure... Send the project.
@gharibissam70334 жыл бұрын
Please chick your email box. Thank you
@gharibissam70334 жыл бұрын
Hello Sir, I'd like to know if you have received my email message. Thank you for help