Hello, I use a Nucleo F103RB, and I have an issue with the debugging/execution phase. Details of clock and choice of prescaler, Counter Period: At the SYSCLK I have 64 MHz, so I have 64 MHz at the HCLK and finally still 64MHz at the APB1 Timer clock, which is used by TIM4. I chose TIM4 in the Pinout & Configuration panel. I check the box for "Internal Clock", because it gives me access to the Parameter Settings, like you in the video for TIM6. There, I put Prescaler at 499. This way, CNT_CLK = 64MHz/(499+1) = 128 000 Hz. Therefore, because ARR= 0.5 * 128 000 = 64 000 < 65535 (maximum at 16bit), I put 499 as prescaler and 64 000 as the Counter Period and I activate auto-reload. Despite all that, and following (I assume correctly) your instructions, putting &htim4 instead of &htim6, et cetera, it does not work! :( I could use the debugger maybe, as you suggested in another comment, but I'm not sure what to check for. One detail about my timers: I don't have a simple "Activated" like you in my Cube IDE. Instead it talks to me about Slave Mode, Trigger Mode, Channel1, 2, 3, 4, et cetera... Please tell me what you think
It's simple mathematics. Basically we are calculating the number of counts required to generate a 0.5sec time base. Thus it's a simple division of time base with a width of one count period (which is the timer period).
Hi, This is video is worth watching. Could you please help me out how to stop the timer interrupt. The Led is continuously blinking. I want to stop the blinking after few mins.
Thanks. One of the simple way of doing this feature is as follows. 1. Implement a static counter variable in the main.c 2. Increment this variable in the period_elapsed callback function 3. monitor value of this variable, and execute toggling action according to this value Recommended way Create a millisecond counter(global static) at the timer interrupt handler (I've not explained this in the video) and apply toggle action according to this value. 2.
Thanks for you explanation. Just one remark for newbees like me. Your callback function is not at the correct position. User code should allways be between a USER CODE BEGIN and a corresponding USER CODE END, otherwise you'll loose your code the next time you make changes in CubeMX. In this situation, I would suggest: /* USER CODE BEGIN 4 */ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin); } /* USER CODE END 4 */
I have done everything same but the led in not blinking I have Nucleo F446RE I have the clock frequency to 170 and rest everything is same as per video I didn't what the error is and how to debug it Hoping for positive response !
Hi Sairaj, sorry for the delay in response. Can you please check if the program goes inside HAL_TIM_PeriodElapsedCallback (@main.c)? You can debug through the pgm by putting a breakpoint inside that function.
Hello, I use a Nucleo F103RB, and I have an issue with the debugging/execution phase.
Details of clock and choice of prescaler, Counter Period:
At the SYSCLK I have 64 MHz, so I have 64 MHz at the HCLK and finally still 64MHz at the APB1 Timer clock, which is used by TIM4.
I chose TIM4 in the Pinout & Configuration panel.
I check the box for "Internal Clock", because it gives me access to the Parameter Settings, like you in the video for TIM6.
There, I put Prescaler at 499. This way, CNT_CLK = 64MHz/(499+1) = 128 000 Hz.
Therefore, because ARR= 0.5 * 128 000 = 64 000 < 65535 (maximum at 16bit), I put 499 as prescaler and 64 000 as the Counter Period and I activate auto-reload.
Despite all that, and following (I assume correctly) your instructions, putting &htim4 instead of &htim6, et cetera, it does not work! :(
I could use the debugger maybe, as you suggested in another comment, but I'm not sure what to check for.
One detail about my timers: I don't have a simple "Activated" like you in my Cube IDE. Instead it talks to me about Slave Mode, Trigger Mode, Channel1, 2, 3, 4, et cetera...
Please tell me what you think
Good day, If possible kindly post one video for HRTIM based buck converter.
Thank you
Hi, Very well explained but how you find the ARR value = time based /Time Periode = 0.01176usec can you please expalin it a little bit ?
It's simple mathematics. Basically we are calculating the number of counts required to generate a 0.5sec time base.
Thus it's a simple division of time base with a width of one count period (which is the timer period).
@@vdevelop thanks a lot , one more question can you please make a tutorial on high Resolution timer ?
Hi, This is video is worth watching. Could you please help me out how to stop the timer interrupt. The Led is continuously blinking. I want to stop the blinking after few mins.
Thanks.
One of the simple way of doing this feature is as follows.
1. Implement a static counter variable in the main.c
2. Increment this variable in the period_elapsed callback function
3. monitor value of this variable, and execute toggling action according to this value
Recommended way
Create a millisecond counter(global static) at the timer interrupt handler (I've not explained this in the video) and apply toggle action according to this value.
2.
Thanks for you explanation. Just one remark for newbees like me. Your callback function is not at the correct position. User code should allways be between a USER CODE BEGIN and a corresponding USER CODE END, otherwise you'll loose your code the next time you make changes in CubeMX.
In this situation, I would suggest:
/* USER CODE BEGIN 4 */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
}
/* USER CODE END 4 */
Exactly, you're correct. I've mentioned this in the latest video i've posted.
Well done thank you
You're welcome.. Thanks for the appreciation ❤️
I have done everything same but the led in not blinking
I have Nucleo F446RE
I have the clock frequency to 170 and rest everything is same as per video
I didn't what the error is and how to debug it
Hoping for positive response !
Hi Sairaj, sorry for the delay in response.
Can you please check if the program goes inside HAL_TIM_PeriodElapsedCallback (@main.c)? You can debug through the pgm by putting a breakpoint inside that function.
@@vdevelop how to debug can you share your video of debugging
How can I make it stop blinking?. Lets say I want it to blink just 10 times
You can declare a variable (count) inside the loop and
If count < 10
Can you share the project files with me ? I'm working on the same nucleo board. I need those files to compare with mines.
Yes. I can create a git repo and will share the link in the description.
@@vdevelop Thanks. I'm waiting for it
I've added the link in the video description. You can visit "04_timer" project. Sorry for the delay!