Page 1 of 1
Accessing DMA NDTR for STM32F4
Posted: Wed Mar 09, 2016 1:50 am
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:
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
Re: Accessing DMA NDTR for STM32F4
Posted: Wed Mar 09, 2016 9:09 am
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
Re: Accessing DMA NDTR for STM32F4
Posted: Wed Mar 09, 2016 3:04 pm
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
Re: Accessing DMA NDTR for STM32F4
Posted: Wed Mar 09, 2016 3:14 pm
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
Re: Accessing DMA NDTR for STM32F4
Posted: Wed Mar 09, 2016 4:05 pm
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!
Re: Accessing DMA NDTR for STM32F4
Posted: Wed Mar 09, 2016 5:16 pm
by Giovanni
Simply use the API with timeout, if the data flow is interrupted or delayed you will get a timeout.
Giovanni
Re: Accessing DMA NDTR for STM32F4
Posted: Thu Mar 10, 2016 8:04 am
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