2023-01-13 09:39 PM
Hi, there!
Please help me !!!
I am testing Timer cascading with F411 Back pill on STM32CubeIDE.
TIM2 [Master] ---> TIM5 (or TIM9) [Slave]
There is no description on Periphral Interconnect Matrix feature in the STM32F4 manual (RM390), but I found the same in that of G4 (RM0440).
According to the manual, TIM2 sends its TRGO to ITR1 channel.
However, in my case, it does not work with ITR1 and I need to use ITR0 instead of ITR1.
More over, if I use ITR1 (in TIM5), TIM2 [Master] does not work.
(Using ITR2 and ITR3 will not affect to TIM2, but TIM5 does not get clock from TIM2.)
Please help,
1) Does anyone know the Periphral Interconnect Matrix feature for STM32F4?
Where can I get the Info.?
2) Can some of you check if the phenomenon above is common to other MCU or not? (Please see the working code below.)
Thank you very much for your kind help in advance.
K.A.
==========================================
Excerpt of the code generated by CubeIDE
==========================================
********************************************
TIM_Callback.c
********************************************
#include "main.h"
extern int cnt, cnt2 ;
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if (htim->Instance == TIM2) {
HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin);
cnt ++ ;
}
if (htim->Instance == TIM9) {
HAL_GPIO_TogglePin(LD0_GPIO_Port, LD0_Pin);
cnt2++ ;
}
}
********************************************
main.c : Only 2 lines below.
****
/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start_IT(&htim9) ;
HAL_TIM_Base_Start_IT(&htim2) ;
/* USER CODE END 2 */
while (1) { }
***
****************************************************
** Timer Settigs: generated by CubeIDE
****************************************************
/**
* @brief TIM2 Initialization Function ==> With 80MHz clock, output 100Hz
* @param None
* @retval None
*/
static void MX_TIM2_Init(void)
{
/* USER CODE BEGIN TIM2_Init 0 */
/* USER CODE END TIM2_Init 0 */
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE BEGIN TIM2_Init 1 */
/* USER CODE END TIM2_Init 1 */
htim2.Instance = TIM2;
htim2.Init.Prescaler = 80-1;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 10000-1;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
{
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM2_Init 2 */
/* USER CODE END TIM2_Init 2 */
}
/**
* @brief TIM9 Initialization Function ==> With 100Hz clock from ITRx, output 25Hz
* @param None
* @retval None
*/
static void MX_TIM9_Init(void)
{
/* USER CODE BEGIN TIM9_Init 0 */
/* USER CODE END TIM9_Init 0 */
TIM_SlaveConfigTypeDef sSlaveConfig = {0};
/* USER CODE BEGIN TIM9_Init 1 */
/* USER CODE END TIM9_Init 1 */
htim9.Instance = TIM9;
htim9.Init.Prescaler = 0;
htim9.Init.CounterMode = TIM_COUNTERMODE_UP;
htim9.Init.Period = 4-1;
htim9.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim9.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim9) != HAL_OK)
{
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_EXTERNAL1;
sSlaveConfig.InputTrigger = TIM_TS_ITR0;
if (HAL_TIM_SlaveConfigSynchro(&htim9, &sSlaveConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM9_Init 2 */
/* USER CODE END TIM9_Init 2 */
}
******* End of File ******
Solved! Go to Solution.
2023-01-14 12:42 AM
JW
2023-01-14 12:42 AM
JW
2023-01-14 01:45 AM