Search code examples
cmicrocontrollerstm32halstm32f4

DMA UART Buffer pointer


I'm using a STM32F4 for receiving data from a FPGA (now it only relays data from a PC) using DMA UART. The DMA UART is working as it should, but it can only give an interrupt when the buffer for the UART it is half full or full. The problem is that I want to know if I got new data in the buffer without it being half or full.

In short I am looking for a register which point to where the next byte from the UART should go in the DMA buffer. Does anyone know of a register like that.

Thank you!


Solution

  • Thanks for the help, I found what I was looking for.

    uint32_t bytesRx DMA1_Stream1->NDTR;
    

    and

    UART_HandleTypeDef huart3;
    uint32_t bytesRx = huart3.hdmarx->Instance->NDTR;
    

    Both of them works for finding how many bytes that have been received, observe that NDTR counts down.