cancel
Showing results for 
Search instead for 
Did you mean: 

Serial DMA buffer position

RD'Ig
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
Max VIZZINI
ST Employee

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.

View solution in original post

2 REPLIES 2
Max VIZZINI
ST Employee

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.

Thank you, this works for my purpouse.

Best regards.