Visitor II
December 21, 2015
Question
[EXAMPLE] HAL based GPIO - DMA transfer TIM triggered
- December 21, 2015
- 0 replies
- 652 views
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
/* 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