2017-02-20 02:43 AM
Hi,
I'm trying to realize a communication between an external ADC with a parallel interface and a STM32F429 via DMA. Therefore the clock-out signal, provided by the ADC (which indicades the new data is ready, at a falling edge) is connected to pin PA9. The alternate function one of PA9 is TIM1_CH2, which i want to use to trigger the DMA by input capture.
I enabled Timer 1 and DMA2. I'm using DMA2 stream 2 channel 6. It seems 'everything' is set up correct, by having a look on the registers with the debugger.
When I try to capture a certain amount of samples, which is equal to the number of data items to be transferred in register DMA_S2NDTR, this value is just decremented by one. Even I implement a wait 'while NDT is larger than zero' this does not halt the processor, by means of just decreasing NDT by one and don't stuck in the while loop.
Unfortunately I'm using ChibiOS, so I'm not able to post appropriate code. For those who are familiar with ChibiOS, I already posted my problem
http://www.chibios.com/forum/viewtopic.php?f=16&t=3812&start=20
.Maybe someone can give me a hint how to set up the DMA and Timer correct to get the communication working.
BR
#dma #timer1_ch2 #peripheral-to-memory #stm32f4292017-02-20 05:22 AM
Check the DMA for error flags. Make sure your memory is not CCM, and not misaligned.
Try with the TIM configured in PWM mode with CH2 firing periodically, confirm the DMA occurs and is paced at expected speed.
2017-02-22 02:07 AM
Hi Clive One,
thank you for your reply. To solve the decrementation problem I had to disable the circular mode, which was enabled. By not using the circular mode, the DMA is disabled when the data items to be transferred in register DMA_SxNDTR are zero.
Further I had a problem with the allocated memory. Now it works! Thank you.
I have a further question. Is it possible to use two DMA2 streams simultaneously? I have to read in 14 GPIO pins. Unfortunately the pins of a single port are unfavorable distributed to realize a proper PCB layout. Thus, a couple of my input pins are connected to port B and the remaining ones are connected to port E. I'm using PA9 in alternate mode 1 (TIM1_CH2) (STM32F429). By having a look at the reference manual it looks like I could use stream 2 channel 6 and stream 6 channel 0 to achieve the simultanous read in.
I tried it but it looks like the data are corrupted.
BR
2017-10-02 04:53 PM
Unfortunately, this is not possible using a single trigger. Per AN4031 (Using the STM32F2, STM32F4 and STM32F7 Series DMA controller - Page 32):
4.6 Twice-mapped DMA requests
When the user configures two (or more) DMA streams to serve the same peripheral request, software should ensure that the current DMA stream is completely disabled (by polling the EN bit in the DMA_SxCR register) before enabling a new DMA stream.
You could route the external ADC clock out signal to two different timer capture inputs (or in some special cases, two different channels on the same timer - Check the DMA Request Mapping table in the Reference Manual) and use those separate triggers for two different DMA streams. But the easiest and most CPU / DMA efficient way would probably be to beat your PCB routing guy with a stick until he gets them routed to the same port.
A bit late for you, but it might help the next person down the line.