ctimerembeddedstm32dma

DMA to GPIO control using timer is not working


I want to control GPIO output using DMA and Timer. The target is generating a CLK signal of 1MHz and control PB0 synchronized with the CLK.

I am using Nucleo-F411RE as the development board. I have followed the instructions from the forum and configured the program.

Configuration:

HCLK: 100MHz

Timer3:

enter image description here

enter image description here

Program in main.c:

uint32_t dummy_data[7] = {0} ;
dummy_data[0] = 0x00000001 ;
dummy_data[1] = 0x00010000 ;
dummy_data[2] = 0x00000000 ;
dummy_data[3] = 0x00000000 ;
dummy_data[4] = 0x00000001 ;
dummy_data[5] = 0x00010000 ;
dummy_data[6] = 0x00000000 ;

HAL_DMA_Start(&hdma_tim3_ch4_up, (uint32_t)dummy_data, (uint32_t)&(GPIOB->BSRR), 7) ;
HAL_TIM_Base_Start(&htim3) ;
HAL_TIM_OC_Start(&htim3, TIM_CHANNEL_4) ;
TIM3->DIER |= (1 << 8 )  ;

I am expecting to see a pulse in PB0 synchronized with PC9(Output compare pin) PWM. But as output, I am getting only 1MHz PWM in PC9 and there is no change in PB0. Am I missing something? Any suggestions would be helpful.


Solution

  • For STM32 F4 there is no connectivity from the DMA1 to AHB peripherals. So, Instead of DMA1 in TIM3, I have configured the TIM1 PWM CN1 (APB2) to trigger the DMA2 Stream 5 in Memory to peripheral mode to write words in GPIOB->BSRR. Now it works (Can write the GPIOB->BSRR register successfully).

    Simply for STM32 F411RE:

    GPIOB(AHB1) is connected with DMA2 (Using DMA2 Stream 5)
    DMA2 is connected with APB2 (Using TIM1 PWM CN1)