AnsweredAssumed Answered

[EXAMPLE] HAL based GPIO - DMA transfer TIM triggered

Question asked by tkroenert on Dec 21, 2015
I spend the last 2 days getting an example to work for DMA transfer from the GPIOC inputs to memory triggered by a timer and based on the HAL-library and thats with a project generated by STM32CubeMX !
This forum helps me a lot, so I thought I could give back and share my code with you.

What does the code?
  • TIM1 Channel4: generating 16MHz on PA11
  • DMA2: copies PC0..PC15 to the memory with 16MHz

These are the most important lines: (the complete example is attached to this post)
/* configure DMA */
HAL_DMA_Start(&hdma_tim1_ch4_trig_com, (uint32_t)&GPIOC->IDR, (uint32_t)&gSamples[0], GSAMPLES_SIZE);
/* TIM1: connect Capture Compare Interrupt of Channel 4 as DMA Request */
/* TIM1: Channel 4 output enable */
HAL_TIM_OC_Start(&htim1, TIM_CHANNEL_4);
/* TIM1: start timer */