AnsweredAssumed Answered

A question about UART interrupt

Question asked by Taehyeong Gu on Apr 18, 2017
Latest reply on Oct 7, 2017 by Clive One

In order to configure UART interrupt receive, I put HAL_UART_Receive_IT function in HAL_UART_RxCpltCallback.

but it doesnt work. below is my callback code.

 

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
uint8_t i;
if (huart->Instance == USART2) //current UART
{
if (Rx_indx==0) {for (i=0;i<RXBUFFERBYTE;i++) aRxBuffer[i]=0;} //clear Rx_Buffer before receiving new data

if (Rx_data[0]!=10) //if received data different from ascii 10
{
aRxBuffer[Rx_indx++]=Rx_data[0]; //add data to Rx_Buffer
}
else //if received data = 10
{
Rx_indx=0;
USART2_RX_STANBY=1;//transfer complete, data is ready to read
}

if(HAL_UART_Receive_IT(&huart2,Rx_data, 1) != HAL_OK)//activate UART receive interrupt every time
{

Error_Handler();
}


}


}

 

The main program has HAL_UART_Receive_IT in beginning part. so i put some character of ASCII and my program reach if(HAL_UART_Receive_IT(&huart2,Rx_data, 1) != HAL_OK) . I checked that HAL_UART_Receive_IT returned HAL_OK then it means preparation of UART receive interrupt. 

but the program doenst take interrupt when I send ASCII to MCU.

 

I have no clue.. anyone who have had same experience??

help me please.

 

Thank you.

Outcomes