Why HAL_UART_Transmit_DMA(&huart2, buffer, n) doesn't work properly inside Timer interrupt callback function?
Greeting Everyone,
May I have some little help here? I'm currently using STM32F303K8. I had experimented with HAL_UART_Transmit_DMA function within "the main while loop" and the TIM6_DAC1_IRQHandler(void) which was called from TIM6 in Time Base mode
My application is to send the current encoder count by UART. It'd be better to send with an determinable rate, that's why I prefer to use Timer.
Here's part of my code when using polling mode(main.c)
/* USER CODE BEGIN 2 */
HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL);
HAL_TIM_Base_Start_IT(&htim6);
//HAL_UART_Receive_DMA(&huart2, pData, Size)
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
char buffer[12];
int n = sprintf(buffer, "%ld\n", TIM2->CNT);
HAL_UART_Transmit_DMA(&huart2, buffer, n);
HAL_Delay(200);
}
/* USER CODE END 3 */Here's when it's come to Timer interrupt mode(stm32f3xx_it.c)
void TIM6_DAC1_IRQHandler(void)
{
/* USER CODE BEGIN TIM6_DAC1_IRQn 0 */
/* USER CODE END TIM6_DAC1_IRQn 0 */
HAL_TIM_IRQHandler(&htim6);
/* USER CODE BEGIN TIM6_DAC1_IRQn 1 */
char buffer[12];
int n = sprintf(buffer, "%ld\n", TIM2->CNT);
HAL_UART_Transmit_DMA(&huart2, buffer, n);
/* USER CODE END TIM6_DAC1_IRQn 1 */
}Clock running at 64MHz
TIM6->PSC = 6399 and TIM6->ARR = 1999
So, the expected interrupt rate is 5Hz (similar to delay(200 ms))
The result between 2 mode is from below
I'm really curious about this, since the frequency is very low, it should have no problem, or am I missing any point?
Thank you
