2025-05-27 4:40 AM - last edited on 2025-05-27 6:24 AM by Andrew Neil
I'm trying to use the DMA engine to drive a GPIO output port, with each update triggered by a timer to achieve a particular waveform. It's trying to run, but I'm getting a TEIF (transfer error flag) and not seeing anything on the GPIO pins. I can't figure out where the problem is.
My targets are:
1. Target Dest GPIO Port F (all 16 bits)
2. TIM4_CH2 (DMA1 -> Channel 2 -> Stream 3). Note that I also have TIM4_CH2 routed to an alternate pin function so I can view the timing, and it is working correctly.
3. Data source is Memory/Internal RAM buffer (uint16_t array)
Here are my register setups:
1) S3NDTR = 0x100 (number of transfers == internal RAM buffer size)
2) S3M0AR = 0x200000c0 (address of internal RAM buffer)
3) S3PAR = 0x40021414 (GPIO F's ODR register)
4) S3FCR = 0x21 (default reset val, leaving in direct mode)
5) S3CR = 0x4032c41
Other notes: I'm following the rules and setting up everything before enabling the "EN" bit. I've tried various combinations of fifo/direct mode, and also trying to change the array/dest size to 32-bits, but still no luck. The DMA1 reset bit is 0 and the DMA1 periph clock enable bit is 1 in the RCC. It wasn't super clear in the timer register section what the TIMx_DIER register needs to be set to, I assume just CC2DE needs to be enabled, but I've also tried UDE, TDE, and various combinations of them.
Any clues as to what I'm missing?
Solved! Go to Solution.
2025-05-27 6:09 AM
DMA1 can't access GPIO. Use DMA2.
2025-05-27 6:09 AM
DMA1 can't access GPIO. Use DMA2.
2025-05-27 7:38 AM
Thank you, I must have missed that detail in the reference manual.