Accessing DMA NDTR for STM32F4

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
samtatasurya
Posts: 22
Joined: Sun Nov 29, 2015 8:13 pm

Accessing DMA NDTR for STM32F4

Post by samtatasurya »

Hi everyone,

I'm currently working with UARTDriver, and I have a question on how to access the "live" value of DMA NDTR.
My idea is using a virtual timer that checks the NDTR value for a fixed interval, e.g. 1uS.

I'm using STM32F4-Discovery and currently trying to access the value via:

Code: Select all

UARTD2.dmarx->stream->NDTR


However, everytime I printed the value to the console, I always get the maximum value (it never showed the value went down).

Can someone point me to how to properly access the "live" value?

Thank you. ;)

- Sam
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Accessing DMA NDTR for STM32F4

Post by Giovanni »

It is unlikely you can use virtual timers for intervals like 1uS, even a real timer couldn't do that because ISR latencies.

Note that the interval is rounded up to the next system tick wich is 100uS in most demos.

Giovanni
samtatasurya
Posts: 22
Joined: Sun Nov 29, 2015 8:13 pm

Re: Accessing DMA NDTR for STM32F4

Post by samtatasurya »

Giovanni wrote:It is unlikely you can use virtual timers for intervals like 1uS, even a real timer couldn't do that because ISR latencies.

Note that the interval is rounded up to the next system tick wich is 100uS in most demos.

Giovanni


Hi Giovanni,

If that is the case, is there any alternative way I can track the value of DMA NDTR?

Because, even if I slowed down the interval, I always got the maximum value passed to the DMA NDTR and never saw it got decremented.

Thank you.

- Sam
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Accessing DMA NDTR for STM32F4

Post by Giovanni »

Very complex.

Forget about printing values in real time with 1uS intervals.

I don't know if this could work: use another DMA channel, triggered by a timer, to read NTDR values and store them into a buffer that you can examine later.

I am missing the point of all this anyway.

Giovanni
samtatasurya
Posts: 22
Joined: Sun Nov 29, 2015 8:13 pm

Re: Accessing DMA NDTR for STM32F4

Post by samtatasurya »

Giovanni wrote:Very complex.

Forget about printing values in real time with 1uS intervals.

I don't know if this could work: use another DMA channel, triggered by a timer, to read NTDR values and store them into a buffer that you can examine later.

I am missing the point of all this anyway.

Giovanni


Hi Giovanni,

The point of what I'm trying to do is to create some kind of a byte tracker for the data that is received via UART.

Because from my understanding, rxend callback only gets called whenever the NDTR reaches 0.
I want to implement a tracker which checks the NDTR on a defined interval, so that my system will know if data transmission gets interrupted in the middle of receiving.
For example, if the NDTR stays on a particular value (>0) for a defined interval, my system will assume that the transmission has been completed instead of waiting for the next bytes until NDTR reaches 0.

Sorry I forgot to mention my intention early on. I hope you would get the idea of what I'm trying to achieve.

Thanks!
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Accessing DMA NDTR for STM32F4

Post by Giovanni »

Simply use the API with timeout, if the data flow is interrupted or delayed you will get a timeout.

Giovanni
samtatasurya
Posts: 22
Joined: Sun Nov 29, 2015 8:13 pm

Re: Accessing DMA NDTR for STM32F4

Post by samtatasurya »

Giovanni wrote:Simply use the API with timeout, if the data flow is interrupted or delayed you will get a timeout.

Giovanni


Hi Giovanni,

I forgot to mention that the ChibiOS version I was using was 3.0.4, which doesn't have the timeout functionalities for UART.
I'll try to use 16.1.4 and see whether I can implement what you suggested.

Thanks!

- Sam
Post Reply