cancel
Showing results for 
Search instead for 
Did you mean: 

uart not enter irq anymore while the port continuously receiving data

Jwu.7
Associate

I use the UART RX DMA mode t​o receive the data from the peripheral. This peripheral could endless send the data after powering up. However after serval rounds UART IRQ handler execution, the UART port couldn’t enter the IRQ handler anymore while the data was still being sent to the UART Rx port.

when the issue happend ,the baudrate was set 460800

UART was set to the DMA correctly and code was verfied.

the IRQ handling was set as below.

void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *uart, uint16_t size)
{
 
    uint32_t id = hal_uart_get_uart_id(uart);
    static uint8_t old_pos = 0;
    static uint8_t recv_length = 0;
    if (size != old_pos) {
        recv_length = size - old_pos;
        // printf("size is %d, old pos is %d,recv length is %d\r\n", size, old_pos, recv_length);
        if (recv_length > RX_BUFFER_SIZE)
            printf("rx handle error occurred\r\n");
        else {
 
            hal_uart[id].receive_cb(hal_uart[id].port, &hal_uart[id].dma_rx_buffer[old_pos],
                                    recv_length);
            if (size >= RX_BUFFER_SIZE)
                old_pos = 0;
            else
                old_pos = size;
        }
    }
}
void DMA1_Stream1_IRQHandler(void)
{
   
    HAL_DMA_IRQHandler(uart->hdmarx); // uart pointer to UART3 handler
}

1 REPLY 1

Perhaps the UART is flagging an error that you fail to clear? Framing, noise, overrun, etc

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..