2018-04-07 07:30 AM
Hello! I'm working with stm32f042 MCU. My task is to read GPIO 8-bit data (7-0 bits) periodically, the faster, the better. I use timer 3 to generate DMA request and DMA channel 4. The idea is the following one: timer periodically generates DMA request on update event, so GPIO->IDR is read. But it doesn't work. Timer doesn't generate DMA request, DMA counter doesn't change, no GPIO reading happens.
Init code
//DMA channel 4
Solved! Go to Solution.
2018-04-07 10:10 AM
2018-04-07 07:36 AM
Init code
//DMA channel 4
RCC->AHBENR |= RCC_AHBENR_DMAEN;
DMA1_Channel4->CPAR = (uint32_t) (&(GPIOA->IDR)); DMA1_Channel4->CMAR = (uint32_t)(GpioData); DMA1_Channel4->CNDTR = Size; DMA1_Channel4->CCR = DMA_CCR_MINC | DMA_CCR_TEIE | DMA_CCR_TCIE; DMA1_Channel4->CCR |= DMA_CCR_EN; NVIC_EnableIRQ(DMA1_Channel4_5_IRQn); NVIC_SetPriority(DMA1_Channel4_5_IRQn,0);//Timer 3
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
//TIM3->CR2 |= TIM_CR2_MMS_1; //tried that, no results TIM3->DIER = TIM_DIER_UDE;//TIM3->DIER |= TIM_DIER_UIE | TIM_DIER_TDE ; //tried that, no results
TIM3->PSC = 47999; TIM3->ARR = 100; TIM3->CR1 |= TIM_CR1_CEN;What am I doing wrong?
2018-04-07 10:10 AM
Incorrect DMA channel?
JW
2018-04-07 02:04 PM
Thank you very much, waclawek.jan! That was it. I thought the source was TIM3_TRIG corresponding DMA channel 4.
By the way, what maximum data frequency can be achieved by using scheme 'timer-DMA-GPIO->IDR'?
2018-04-07 03:50 PM
Thank you.
2018-04-07 05:06 PM
See AN2548 .
JW