2019-02-06 08:58 AM
I see that times can be initiated by ITR0, ITR1 in CubeMX etc. I understand that it is internal interrupt. I do not how to set for example another timer to turn another timer on and off.
I do not see in CubeMX any option to setup one timer as global interrupt for example ITR0
although I know how to start timer as interrupe for example HAL_TIM_Start_IT(&htim1); in HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) and it works fine when I test the blinking LED for example But it has nothing to do with ITR0, ITR1, ITR2, ITR3 you see on CubeMX
2019-02-06 09:45 AM
You may want to read the TImer chapter in the Reference Manual, concentrating on the description of TIMx_SMCR register, TS and SMS fields; and then also TIMx_CR2.MMS.
JW
2019-02-06 11:34 AM
They are Input Triggers (Sources) for the TIM, in the same manner TRGO are the trigger output choices.
The Reference Manual should have tables relating the options for each of the TIM, ie that TIMx has input choices from TIMa, TIMb, TIMc or TIMd, and each of those TIM has a choice for its output source.
2019-02-06 01:23 PM
if I was so smart like you to understand all the high tech mumbling in those manuals I would not come here for advice. So if you cannot answer the question how to get the ITR0 working with some exaple better do not aswear at all
2019-02-09 04:37 PM
So I prepared a simple example for the L4 DISCO to demonstrate how one timer can turn another timer on and off (http://www.efton.sk/STM32/tim_master_slave_gated.zip , needs http://www.efton.sk/STM32/stm32l476xx.zip ).
TIM2 is run relatively slowly, overflowing once in 3 seconds, and one channel in it is set to PWM so that it's ON for 2 seconds and OFF for 1 second, (its output is connected to red LED on the bosrd). and that is set to be TRGO
TIM1 is run to produce a 10Hz PWM on CH1 (rapid blinking, seen on green LED). It is set as a slave in Gated mode (see SMS field of TIM1_SMCR), and in TIM1_SMCR.TS, the applicable master is set - here, ITR1 is chosen, which for TIM1 is TIM2.
https://community.st.com/sfc/servlet.shepherd/document/download/0690X000006DT7HQAW
JW
2019-02-10 05:35 AM
thanks, I was hoping something simpler to setup in Cube Mx. Assembler is a chalange if you are beginer. I do not have this specific board to test,
2020-09-03 02:59 AM
Let's say you want to use the TIM1 as your slave. You then go to the reference manual of the processor and look for the TIMx Internal trigger connection table in the section called: "TIM1 slave mode control register (TIM1_SMCR)".
This table will tell you that if you want to use the input of say TIM3 as your clock for the slave then as per the table you will find that under ITR2 you find TIM3. This means that for TIM1 used as a slave the internal input trigger source to select is ITR2 so that it listens to TIM3 as the source as shown in the TIMx Internal trigger connection table for the TIM1.
This means that in this particular case your internal source will be ITR2 so in STM23CubeMX you setup TIM1 as slave and set its trigger source to ITR2 so that it listens to TIM3 as the source clock for TIM1 behaving as slave mode.
Doing so when generating code STM32CubeMX generates this code:
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_EXTERNAL1;
sSlaveConfig.InputTrigger = TIM_TS_ITR2;
if (HAL_TIM_SlaveConfigSynchro(&htim1, &sSlaveConfig) != HAL_OK)
{
Error_Handler();
}
Let's say now that in the same application you want to use TIM15 as your slave and you also want to use the TIM3 as your clock source forthe TIM15 slave. This time you search for TIM15 control register 2 (TIM15_CR2) in the reference manual and you'll find the TIMx Internal trigger connection table for the TIM15.
In this case even though you're still using the same TIM3 as a source you need to use Input Trigger ITR1 as the internal trigger source so that TIM15 listens to TIM3 as its clock . You apply the same selections as before to the STM32CubeMX and it will generate the correct code for it just like before.
2021-12-13 08:35 PM
Thanks for the great explanation.