UART and timer interrupt issue
Hello! Can you help me?
I'm receiving data in UART Rx with DMA and send it by USB, it works fine. Now i'm trying to set up a timer to check if I'm receiving data every 250[ms] and send a special message. When I don't configure the timer it works, but when I add the timer and receive data, I only send the special message even when it should send the UART Rx data.
This is my UserDataTreatment function, called inside the UART+DMA callback
void UserDataTreatment(UART_HandleTypeDef *huart, uint8_t* pData, uint16_t Size){
if(huart->Instance == USART1){
uint8_t* pBuff = pData;
uint8_t i;
uint8_t DataArray[USB_BUFFER_SIZE];
for (i = 0; i < Size; i++){
DataArray[i] = *pBuff;
pBuff++;
}
__HAL_TIM_SetCounter(&htim2, 0);
CDC_Transmit_FS(DataArray, Size);
}
}And this is my period elapsed callback
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim){
if(htim->Instance == TIM2){
CDC_Transmit_FS(disconectMSG1, 5);
}
}The idea is to set up a timer, reset it in the UART callback, so if I don't don't receive data, the timer overflows and send the special message.
Thank you!
