2021-12-13 12:12 PM
My goal is to send bit patterns from an array directly to GPIO, using a Timer as a sample clock / DMA trigger.
More concretely: TIM2 Update Event --> DMA --> memory to GPIO Port ODR transfer
I am on STM32f103rb (Nucleo-64)
Similar questions have been asked here, of which none helped me so far.
https://community.st.com/s/question/0D50X0000C7eDobSQE/dma-gpio-stm32f103
I use the following initialization of the TIM2 peripheral and the code below to start the DMA. Pins PC0 to PC3 are configured as outputs.
On the oscilloscope I get the TIM2_CH1 Output Compare signal at 500 Hz.
But the DMA does not affect the GPIOC->ODR state. Why?
/* USER CODE BEGIN 2 */
uint16_t pixelclock[8] = {0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000};
HAL_DMA_Start(&hdma_tim2_up, (uint32_t)pixelclock, (uint32_t)&(GPIOC->ODR), 8);
HAL_TIM_Base_Start(&htim2);
HAL_TIM_OC_Start(&htim2, TIM_CHANNEL_1);
/* USER CODE END 2 */
Debugger state:
Solved! Go to Solution.
2021-12-13 12:32 PM
HAL isn't set up to do this, but it can be done.
Ensure UDE is set in TIMx_DIER. If that's not it, show the contents of the TIM2 registers.
2021-12-13 12:32 PM
HAL isn't set up to do this, but it can be done.
Ensure UDE is set in TIMx_DIER. If that's not it, show the contents of the TIM2 registers.
2021-12-13 12:37 PM
That was it!
Thank you so much 🙂
2021-12-13 12:41 PM
Glad to help. Consider using the GPIOx_BSRR register instead (with 32-bit words) in order to change only PC0-PC3 and leave PC4-PC15 alone.
2021-12-13 11:26 PM
Done! Thanks for all the hints. For anyone looking for the full code: