2024-09-27 06:33 AM
I want tim16 to, every 1 second, start tim15 which is a oneshot timer which then does something when the period elapsed.
I start tim16 in my main function, which works correctly, but the tim15 interrupt only triggers once, so my output looks like this:
First!
Second!
First!
First!
First!
...
Here is my code:
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim == &htim16)
{
const char* message = "First!\r\n";
HAL_UART_Transmit(&huart2, (uint8_t*)message, strlen(message), HAL_MAX_DELAY);
HAL_TIM_Base_Start_IT(&htim15);
}
else if(htim == &htim15)
{
const char* message = "Second!\r\n";
HAL_UART_Transmit(&huart2, (uint8_t*)message, strlen(message), HAL_MAX_DELAY);
}
}
Solved! Go to Solution.
2024-09-27 06:47 AM
2024-09-27 06:47 AM
Needed to add
HAL_TIM_Base_Stop_IT(&htim15);