Skip to main content
RD'Ig
Associate II
October 15, 2021
Solved

Serial DMA buffer position

  • October 15, 2021
  • 1 reply
  • 1763 views

Hi,

I am developing an application on SPC58EC that uses the serial with DMA for reading.

I'd like to know if there is a way to know and get the position where it's writing in the buffer. I mean something like the corresponding "__HAL_DMA_GET_COUNTER(...)" or to the "...->CNDTR" register of the STM32.

I already use the receive callback that trigger at the end, but it's not enough for my purpose.

Thanks,

Rob

This topic has been closed for replies.
Best answer by Max VIZZINI

hi Rob,

I confirm that there is not such a command in the driver to get the writing position in the buffer.

One idea would be to extract it from the running task.

If we look at the serial peripheral configuration sd_rx/tx_dma, we shall find the following DMA setup: t

edmaChannelSetup(

                  sdp->rx_channel,            /* channel.                */

                  ((vuint32_t)&sdp->linflexlp->BDRM) + 3U, /* src.        */

                  rxbuf,                      /* dst.                    */

                  0,                          /* soff, do not advance.   */

                  1,                          /* doff, advance by 1.     */

                  0,                          /* ssize, 8 bits transfers. */

                  0,                          /* dsize, 8 bits transfers. */

                  1,                          /* nbytes, always one.     */

                  n,                          /* iter.                   */

                  0,                          /* slast, no source adjust. */

                  0,                          /* dlast, no dest.adjust.  */

                  EDMA_TCD_MODE_DREQ | EDMA_TCD_MODE_INT_END); /* mode.   */

It should be sufficient to extract the information from "iter" from the DMA running node. This value should be decremented with every transmission.

Num_bytes_transferred = 1 * edmaGetTCD(***).n

I hope this could work.

1 reply

Max VIZZINI
Max VIZZINIBest answer
Technical Moderator
October 21, 2021

hi Rob,

I confirm that there is not such a command in the driver to get the writing position in the buffer.

One idea would be to extract it from the running task.

If we look at the serial peripheral configuration sd_rx/tx_dma, we shall find the following DMA setup: t

edmaChannelSetup(

                  sdp->rx_channel,            /* channel.                */

                  ((vuint32_t)&sdp->linflexlp->BDRM) + 3U, /* src.        */

                  rxbuf,                      /* dst.                    */

                  0,                          /* soff, do not advance.   */

                  1,                          /* doff, advance by 1.     */

                  0,                          /* ssize, 8 bits transfers. */

                  0,                          /* dsize, 8 bits transfers. */

                  1,                          /* nbytes, always one.     */

                  n,                          /* iter.                   */

                  0,                          /* slast, no source adjust. */

                  0,                          /* dlast, no dest.adjust.  */

                  EDMA_TCD_MODE_DREQ | EDMA_TCD_MODE_INT_END); /* mode.   */

It should be sufficient to extract the information from "iter" from the DMA running node. This value should be decremented with every transmission.

Num_bytes_transferred = 1 * edmaGetTCD(***).n

I hope this could work.

RD'Ig
RD'IgAuthor
Associate II
October 27, 2021

Thank you, this works for my purpouse.

Best regards.