Unable to get DMA to GPIO working on STM32F411
- September 20, 2020
- 2 replies
- 2248 views
I'm new to using the STM32, coming from AVR. I'm trying to switch in order to take advantage of DMA but I can't get it working. I have a Nucleo STM32F411re.
I've generated a new project, configured a few pins on GPIOC as output, configured TIM1 to use an internal clock, and generate a PWM out on CH1, and configured a DMA to use TIM_UP (DMA2 Stream 5) Memory to Peripheral.
in the code I start the PWM output -- this works and I see it on the scope.
if (HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
then I try to start the DMA transfer - this doesn't work.
if (HAL_DMA_Start(&hdma_tim1_up, (uint32_t)data, ((uint32_t)&(GPIOC->ODR)), 16) != HAL_OK) {
Error_Handler();
};
I'm not sure what I'm doing wrong. I've read a lot of forum posts about this with mixed results but even when I follow the examples that claim to work they don't work for me.
Eventually I'd like to get it working with 11 data lines and 1 clock line and would like to use interrupts and circular mode but I'm happy to just get the basics working first.