cancel
Showing results for 
Search instead for 
Did you mean: 

[EXAMPLE] HAL based GPIO - DMA transfer TIM triggered

tkroenert
Associate
Posted on December 21, 2015 at 14:09

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 s.th 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 */
__HAL_TIM_ENABLE_DMA(&htim1, TIM_DMA_CC4);
/* TIM1: Channel 4 output enable */
HAL_TIM_OC_Start(&htim1, TIM_CHANNEL_4);
/* TIM1: start timer */
HAL_TIM_Base_Start(&htim1);

#stm32cubemx #hal #dma #tim
0 REPLIES 0