DMA sampling of GPIO + Ethernet transfer -> sample loss
Posted: Wed Jun 20, 2018 4:15 pm
Hello,
I am using the DMA of the STM32F746 to sample half a port of the GPIO (8 bits per transfer, FIFO burst enabled, very high priority) from a parallel port ADC. I sample at a rate of 20 MHz with a system clock of 200 MHz. Transfers directly go to an SDRAM memory area.
The DMA is triggered by the ICU that reacts to a rising edge at a timer pin.
After I finish a DMA transfer (e.g. 32k samples) I transfer the memory content over Ethernet to a PC for evaluation using the TCP protocol with zero-copy (DMA-based). DMA transfers from the GPIO pins are triggered every second and transfers to PC directly happen afterwards, meaning that I have a continuous data stream.
I tested two cases:
1) Ethernet transmission of data disabled:
The DMA sampling works fine and I get all the samples I want from the ADC. I can control the NTDR register at the end of the sampling pulses and it always returns to the initial total transfer count.
2) Ethernet transmission of data enabled:
DMA sampling mostly works but sometimes samples are dropped. The DMA does not react to the trigger and misses data from the ADC. The NTDR register shows some value other than the total transfer count after the sampling pulses.
I have two assumptions as to why this happens:
a) The bus is full by having so many memory accesses
b) The DMA priority for the MAC is higher than for my ADC sampling (I set it to 3) and samples are lost due to the DMA not being active when triggered
I run the latest Chibios 18.
I would be happy to hear your thoughts!
Adrian
I am using the DMA of the STM32F746 to sample half a port of the GPIO (8 bits per transfer, FIFO burst enabled, very high priority) from a parallel port ADC. I sample at a rate of 20 MHz with a system clock of 200 MHz. Transfers directly go to an SDRAM memory area.
The DMA is triggered by the ICU that reacts to a rising edge at a timer pin.
After I finish a DMA transfer (e.g. 32k samples) I transfer the memory content over Ethernet to a PC for evaluation using the TCP protocol with zero-copy (DMA-based). DMA transfers from the GPIO pins are triggered every second and transfers to PC directly happen afterwards, meaning that I have a continuous data stream.
I tested two cases:
1) Ethernet transmission of data disabled:
The DMA sampling works fine and I get all the samples I want from the ADC. I can control the NTDR register at the end of the sampling pulses and it always returns to the initial total transfer count.
2) Ethernet transmission of data enabled:
DMA sampling mostly works but sometimes samples are dropped. The DMA does not react to the trigger and misses data from the ADC. The NTDR register shows some value other than the total transfer count after the sampling pulses.
I have two assumptions as to why this happens:
a) The bus is full by having so many memory accesses
b) The DMA priority for the MAC is higher than for my ADC sampling (I set it to 3) and samples are lost due to the DMA not being active when triggered
I run the latest Chibios 18.
I would be happy to hear your thoughts!
Adrian