Author Topic: STM32F103C8 DMA to GPIO  (Read 2681 times)

0 Members and 1 Guest are viewing this topic.

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
STM32F103C8 DMA to GPIO
« on: April 02, 2018, 10:14:23 am »
Hello all,

I'm trying to setup a a configuration using DMA to GPIO on a STM32F103C8 microcontroller for use with a display that has 8bits parallel interface (ILI9481). I've found the following application note AN4666 that guides through the process of using a timer in pwm mode and it will also be responsible for the DMA requests but I have some doubts.

so far I have the timer set and the following DMA1 CH2 configuration adapter from an example as I intend to use channel 1 of Timer 1 as the trigger:


Code: (c) [Select]
    DMA_HandleTypeDef hdma_tim1;
    __HAL_RCC_DMA1_CLK_ENABLE();

    hdma_tim1.Instance = DMA1_Channel2;
    hdma_tim1.Init.Direction = DMA_MEMORY_TO_PERIF;
    hdma_tim1.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_tim1.Init.MemInc = DMA_MINC_ENABLE;
    hdma_tim1.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; //8 bits
    hdma_tim1.Init.MemDataAlignment = DMA_PDATAALIGN_BYTE;
    hdma_tim1.Init.Mode = DMA_NORMAL;
    hdma_tim1.Init.Priority = DMA_PRIORITY_LOW;
    HAL_DMA_Init(&hdma_tim1);

    __HAL_LINKDMA(&htim1,hdma[TIM_DMA_ID_CC1],hdma_tim1);
    htim1->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = data_tramsmitted_handler;
    htim1->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = transmit_error_handler;
    HAL_DMA_Start_IT(htim1.hdma[TIM_DMA_ID_CC2],(uint32_t)&my_data_buf, (uint32_t)&GPIOA->ODR, my_data_buf_length);

I understand almost everything but this:
Code: [Select]
    __HAL_LINKDMA(&htim1,hdma[TIM_DMA_ID_CC1],hdma_tim1);

also after starting the dma transfer do I have to manually start the pwm and when the XferCpltCallback is called do I have to manually stop the pwm signal?

thanks in advanced,
Best regards, Mauro.




« Last Edit: April 02, 2018, 10:24:07 am by maurosmartins »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf