I am trying to use timer peripheral in STM32L073 but i have problems. I've generated setup code in STM32Cube and using only functions that HAL API provides. Problem is that timer interrupt occurs only once and it should occur always then it overflows. I don't know if timer is even running or my setup is wrong (which I believe it shouldn't be since I am using Cube generated code). Anyone can help?
This is called in main before while loop
void MX_TIM7_Init(void){
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
htim7.Instance = TIM7;
htim7.Init.Prescaler = 00;
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
htim7.Init.Period = 00;
if (HAL_TIM_Base_Init(&htim7) != HAL_OK) {
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig) != HAL_OK){
_Error_Handler(__FILE__, __LINE__);
}
}
BaseMspInit Method
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle){
if(tim_baseHandle->Instance==TIM7){
/* USER CODE BEGIN TIM7_MspInit 0 */
/* USER CODE END TIM7_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM7_CLK_ENABLE();
/* TIM7 interrupt Init */
HAL_NVIC_SetPriority(TIM7_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM7_IRQn);
/* USER CODE BEGIN TIM7_MspInit 1 */
/* USER CODE END TIM7_MspInit 1 */
}
}
Then in main I call this
HAL_TIM_Base_Start_IT(&htim7);
which is doing this
HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim){
/* Check the parameters */
assert_param(IS_TIM_INSTANCE(htim->Instance));
/* Enable the TIM Update interrupt */
__HAL_TIM_ENABLE_IT(htim, TIM_IT_UPDATE);
/* Enable the Peripheral */
__HAL_TIM_ENABLE(htim);
/* Return function status */
return HAL_OK;
}
and my Interrupt handler calls PeriodElapsedCallback
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
HAL_GPIO_TogglePin(led_GPIO_Port, led_Pin);
}
It compiles there are no errors no warning, in debugger I see this interrupt is triggered only once and then never. Looking forward for answers
P.S. using SEGGER Embedded Studio