I'm developing a software for the STM32l432KC (NUCLEO-L432KC) which uses 2 UARTS with DMA (RX DMA mode to DMA_CIRCULAR) using HAL.

My problem seems to be quite common: the UART buffer length is highly variable (from 12 to 256 characters).

I searched and found out that there is a Receiver timeout interrupt, but how may I implement a callback function to be invoked after an Receiver timeout event occurred?

Is there any sample project showing how to do this?

My RX Complete handler looks like this:

void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart) {
    static uint8_t lf_counter = 0;

    /* if line received from host */
    if (huart == &huart2) {
        uint8_t length=strlen((char*)tx_buffer_2_dma);

        for(int i=0; i<length; i++){
            push_fifo(&host_fifo, tx_buffer_2_dma[i]);

        HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.