cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F1 DMA+GPIO Issue?

ferhatyol-23
Senior

I need to transfer parallel data via GPIO and DMA. The microprocessor I use is STM32F103C8

I need to transfer some memory data to GPIO quickly.

I've written an init code using STM32F103 and the HAL library. But DMA doesn't work. At the end of the process I need to observe the data in the GPIOA.

In addition, the DMA TC interrupt is never generated.

this is my initial code.

my_buf[0]=0x01;

my_buf[1]=0x81;

my_buf[2]=0x02;

my_buf[3]=0x82;

my_buf[4]=0x03;

my_buf[5]=0x83;

my_buf[6]=0x04;

my_buf[7]=0x84;

my_buf[8]=0x05;

  my_buf[9]=0x85;

my_buf[10]=0x06;

my_buf[11]=0x86;

my_buf[12]=0x07;

my_buf[13]=0x87;

my_buf[14]=0x08;

my_buf[15]=0x88;

my_buf[16]=0x09;

my_buf[17]=0x89;

my_buf[18]=0x0A;

  my_buf[19]=0x8A;

my_buf[20]=0x0B;

my_buf[21]=0x8B;

my_buf[22]=0x0C;

my_buf[23]=0x8C;

my_buf[24]=0x0D;

my_buf[25]=0x8D;

my_buf[26]=0x0E;

my_buf[27]=0x8E;

my_buf[28]=0x0F;

  my_buf[29]=0x8F;

void GPIO_DMA_Init(void)

{

 __HAL_RCC_GPIOA_CLK_ENABLE();

__HAL_RCC_DMA1_CLK_ENABLE(); //Enable DMA1

GPIOA->CRL=0x33333333;  

GPIOA->CRH=0x33333333;

 DMA_InitStruct.Instance = DMA1_Channel3;

 DMA_InitStruct.Init.Direction = DMA_MEMORY_TO_PERIPH;

 DMA_InitStruct.Init.PeriphInc = DMA_PINC_DISABLE;

 DMA_InitStruct.Init.MemInc = DMA_MINC_ENABLE;

 DMA_InitStruct.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; // 8 bits

 DMA_InitStruct.Init.MemDataAlignment = DMA_PDATAALIGN_BYTE;

 DMA_InitStruct.Init.Mode = DMA_NORMAL;

 DMA_InitStruct.Init.Priority = DMA_PRIORITY_LOW;

if (HAL_DMA_Init(&DMA_InitStruct) != HAL_OK)

 {

  _Error_Handler(__FILE__, __LINE__);

 }

 HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0); // enable DMA IRQ

 HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);

}

when I want the start transfer, I called the start_transfer function.

void start_transfer(void)

{

 if(HAL_DMA_Start_IT(&DMA_InitStruct,(uint32_t)&my_buf, (uint32_t)&GPIOA->ODR, 30)!=HAL_OK)

 {

   /* Transfer Error */

  Error_Handler();

 }

}

Where can I be making a mistake? Is it possible to transfer data using DMA and GPIO?

5 REPLIES 5

>>Is it possible to transfer data using DMA and GPIO?

Definitely

>>Where can I be making a mistake? 

You fail at something, does the DMA flag a transfer error or something? I'd hazard that ODR is 16-bit wide.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

You need some source of requests (which trigger individual transfers).

Or you can try memory-to-memory mode, instead of memory-to-peripheral.

JW

S.Ma
Principal

An alternate way to push internal memory data would be to use external memory interface (FMC type) whichever acronysm is depending on the STM32 family. It will at least provide HW handshake on top of very high speed GPIO toggling. LCD Examples and source code using 8 bit parallel interface (8080 or 6800) would be a good starting point for hacking to get what's wanted.

ferhatyol-23
Senior

I understand that an external trigger source is needed in Memory to Peripheral mode. Therefore, there is no trigger signal from any hardware, so there is no transmission. is it True?

I will try the Memory to Memory mode.

Is it possible to transfer parallel data with FSMC? I only need to generate 8 bit data + Clock signals. How do I do this with DMA? The transfer speed needs to be very fast.

ferhatyol-23
Senior

Unfortunately, it did not work. Memory to Memory mode did not work. I think it's not possible to use DMA + GPIO in low-level microcontrollers. I think it's not possible to use DMA + GPIO in Medium Density microcontrollers.