2021-03-06 12:47 AM
Hello guys,
I previously asked the question about the UART interrupt but not get any reply.
Currently am able to receive data from uart interrupt but not able to clear the buffer to get new data.
please help.
my code is
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
char temp;
/* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART1_IRQn 1 */
if(USART1->ISR & USART_ISR_RXNE) //UART read data register not empty
{
temp = USART1->RDR; //fetching data register
RX_buffer[m++] = temp; //storing data in buffer
while(!(USART1->ISR & USART_ISR_TC));
}
}
When I send first AT command I receive data in the RX_buffer. when I send next AT+ command the incoming data get append to the previous output.
2021-03-06 07:50 AM
It does exactly what you have implemented. If you want it to reset the buffer, then implement it!
Anyway, joggling around without understanding is a dead-end. If you actually want to learn, then start with the basics:
2021-03-06 10:07 AM
No bounds checking on the buffer.
Doesn't reset the counter.
Hard loops randomly in the middle of the IRQHandler against an unrelated interrupt source, ie receiving, and blocking on transmit complete.