2019-07-05 06:31 PM
I'm trying to set up TIM2 timer on my NUCLEO-H743ZI2 board (STM32H743ZI MCU) to start TIM2 timer on a rising edge of a GPIO input pin. I'm using STM32CubeIDE with STM32CubeMx plugin. Is it possible to set up the hardware to start the timer automatically without calling HAL API to start the timer from the GPIO EXTI interrupt callback function? The timer seems to have lots of trigger inputs for this, but I'm not sure how to route GPIO inputs to timers. Thanks!
Solved! Go to Solution.
2019-07-06 02:55 AM
Most likely You need TIMx_SMCR field SMS set to "Combined reset + trigger mode" (note that bit SMS[3] is actually separate bit 16 in that register). And for input trigger You have two options:
2019-07-06 02:55 AM
Most likely You need TIMx_SMCR field SMS set to "Combined reset + trigger mode" (note that bit SMS[3] is actually separate bit 16 in that register). And for input trigger You have two options:
2019-07-06 03:51 AM
> how to route GPIO inputs to timers
You can't route an arbitrary pin to a timer. Look at the pin assignment table in the datasheet, there are pins labeled TIMx_CHy, you can use only them for TIMx.
You set them in the respective GPIOx_MODER as AF, and then chose the proper AF number in GPIOx_AFR.
Then you set up the timer as Piranha said above.
There's probably a way how to do this by some wild clicking in CubeMX; I don't know, I don't use CubeMX.
JW
2019-07-08 04:21 PM
I didn't know how TIMx_ETR pins worked, but now I understand what they're for. Thank you so much! This solved my problem.
By the way, this turns out to be easy to set up via CubeMx, except it gets confusing when you have to choose between trigger sources "ETR1" and "ETR1 through remap". I chose "ETR1" as my trigger source, and it worked. Also, "Combined reset + trigger mode" didn't work for me since I was using a button to trigger the timer, and CubeMx didn't have a drop-down to select triggering on a rising edge only. So I changed the slave mode to "Trigger Mode", and it worked like a charm.
Thanks again!
2021-08-25 05:43 AM
Hi @Piranha ,@Community member
My requirement is to start timer from a gpio pin (TIMx_ETR) and when gpio pin set i want to toggle the led pin using timer callback function.
I have followed the instructions as you mentioned and added implementation of toggle pin in HAL_TIM_TriggerCallback() but iam unable to toggle the pin , can you please explain the steps after configuring using Cube MX.
what do we need to add in the main.c to work properly after configuring using CubeMX.