2025-10-27 11:15 AM
I am unable to control GPIO output pins with the H5 GPDMA. I am able to control GPIO with the F103 using this project...
https://github.com/mnemocron/STM32_PatternDriver
...where the DMA is much simpler. Section 3.7 of AN5593 (How to use the GPDMA for STM32 MCUs) doesn't provide much information on GPIO control, but does mention using memory-to-memory transfers. I have tried both memory-to-memory and memory-to-peripheral circular DMA transfers without success. Like the F103 example, I am using the TIM2 output compare CH1 as the request event for a DMA transfer. My scope indicates that TIM2 CH1 is toggling properly every millisecond, but no signal comes from the GPIO pins. I've tried myriad permutations of modes and requests/triggers with no success.
Can someone please provide help or a link to a GPDMA project that controls GPIO?
HAL_TIM_Base_Start(&htim2);
for (int i=0; i < sizeof(pixelclock); i++)
pixelclock[i] = 0;
// the pixelclock goes straight to the BSRR register
// [31 ... 16] are reset bits corresponding to Ports [15 ... 0]
// [15 ... 0] are set bits corresponding to Ports [15 ... 0]
// if a reset bit is set, the GPIO port will be set LOW
// if a set bit is set, the GPIO port will be set HIGH
pixelclock[ 0] = 0x00000001; // set SI signal on 1st clock edge
pixelclock[ 2] = 0x00010000; // reset SI signal on 3rd clock edge
pixelclock[ 9] = 0x00000002; // set the ESH signal high
pixelclock[13] = 0x00020000; // set the ESH signal low
status = HAL_DMA_Init(&handle_GPDMA2_Channel0);
if (HAL_OK == status) {
// DMA, circular mode, full word (32 bit) transfer
status = HAL_DMA_Start(&handle_GPDMA2_Channel0, (uint32_t)pixelclock, (uint32_t)&(GPIOC->BSRR), sizeof(pixelclock));
if (HAL_OK == status) {
HAL_TIM_OC_Start(&htim2, TIM_CHANNEL_1);
TIM2->DIER |= TIM_DIER_UDE; // set UDE bit (update dma request enable)
}
}
while (1) { TIM2 Parameters
TIM2 GPDMA2
2025-10-27 2:05 PM
Hello @rmilne and welcome to the Community,
Please find the STM32H5 workshop which contains the step-by-step GPDMA examples with basic peripheral use cases, such as GPIO control: