Incorrect interrupt time
Hi everyone,
I'm using Nucleo H723 board. I have used 8 timers in encoder mode to read the encoders. I have also activated another timer to make an interrupt every 4ms to send the data via Usart.
everything work good but when I use sprint code to put the data in Usart, the interrupt time has been changed and it's not 4ms.
Part of my code inside interrupt:
/* USER CODE BEGIN 4 */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
timer2 = __HAL_TIM_GET_COUNTER(&htim2);
timer5 = __HAL_TIM_GET_COUNTER(&htim5);
timer23 = __HAL_TIM_GET_COUNTER(&htim23);
timer24 = __HAL_TIM_GET_COUNTER(&htim24);
timer1 = __HAL_TIM_GET_COUNTER(&htim1);
timer3 = __HAL_TIM_GET_COUNTER(&htim3);
timer4 = __HAL_TIM_GET_COUNTER(&htim4);
timer8 = __HAL_TIM_GET_COUNTER(&htim8);
count_FL_1=timer1/4;
count_FR_1=timer3/4;
count_RR_1=timer5/4;
count_RL_1=timer23/4;
count_FL_2=timer2/4;
count_FR_2=timer4/4;
count_RR_2=timer8/4;
count_RL_2=timer24/4;
sprintf(buffer_FL_1, "FL_1: %ld\n", count_FL_1);
sprintf(buffer_FR_1, "FR_1: %ld\n", count_FR_1);
sprintf(buffer_RR_1, "RR_1: %ld\n", count_RR_1);
sprintf(buffer_RL_1, "RL_1: %ld\n", count_RL_1);
sprintf(buffer_FL_2, "FL_2: %ld\n", count_FL_2);
sprintf(buffer_FR_2, "FR_2: %ld\n", count_FR_2);
sprintf(buffer_RR_2, "RR_2: %ld\n", count_RR_2);
sprintf(buffer_RL_2, "RL_2: %ld\n", count_RL_2);
HAL_UART_Transmit(&huart3, (uint8_t *) buffer_i,strlen(buffer_i), 100);
HAL_UART_Transmit(&huart3, (uint8_t *) buffer_FL_1,strlen(buffer_FL_1), 100);
HAL_UART_Transmit(&huart3, (uint8_t *) buffer_FR_1,strlen(buffer_FR_1), 100);
HAL_UART_Transmit(&huart3, (uint8_t *) buffer_RR_1,strlen(buffer_RR_1), 100);
HAL_UART_Transmit(&huart3, (uint8_t *) buffer_RL_1,strlen(buffer_RL_1), 100);
HAL_UART_Transmit(&huart3, (uint8_t *) buffer_FL_2,strlen(buffer_FL_2), 100);
HAL_UART_Transmit(&huart3, (uint8_t *) buffer_FR_2,strlen(buffer_FR_2), 100);
HAL_UART_Transmit(&huart3, (uint8_t *) buffer_RR_2,strlen(buffer_RR_2), 100);
HAL_UART_Transmit(&huart3, (uint8_t *) buffer_RL_2,strlen(buffer_RL_2), 100);
i++;
j=i/1000;
}Hier is my timer configuration.
when I delete the sprint codes the timer 4ms runs again correctly.
I appreciate it if you help me.