cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F10x Timer + DMA + GPIO Parallel Data Transfer

ferhatyol-23
Senior
Posted on June 23, 2018 at 23:22

Hi

I want to parallel data transfer via DMA. I am trying to transfer an array in memory to the GPIO. For this, I thought it would trigger the DMA with the Timer Update event. In this way, I can move the data in memory to the GPIO. 

In order to do this I have prepared the following init code.

void HUB75_Tim_DMA_Init(void)

{

__HAL_RCC_TIM3_CLK_ENABLE(); //Enable TIM3;

__HAL_RCC_DMA1_CLK_ENABLE(); //Enable DMA1

TIM_InitStruct.Instance = TIM3;

TIM_InitStruct.Init.Prescaler = 72-1;

TIM_InitStruct.Init.CounterMode = TIM_COUNTERMODE_UP;

TIM_InitStruct.Init.Period = 1000-1;

TIM_InitStruct.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

TIM_InitStruct.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

TIM_InitStruct.Init.RepetitionCounter = 0;

if (HAL_TIM_Base_Init(&TIM_InitStruct) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

DMA_InitStruct.Instance = DMA1_Channel2;

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_HALFWORD; // 16 bits

DMA_InitStruct.Init.MemDataAlignment = DMA_PDATAALIGN_HALFWORD;

DMA_InitStruct.Init.Mode = DMA_CIRCULAR;

DMA_InitStruct.Init.Priority = DMA_PRIORITY_LOW;

if (HAL_DMA_Init(&DMA_InitStruct) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

__HAL_LINKDMA(&TIM_InitStruct,hdma[TIM_DMA_ID_UPDATE],DMA_InitStruct);

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

HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn);

__HAL_TIM_ENABLE_DMA(&TIM_InitStruct, TIM_DMA_UPDATE);

__HAL_TIM_ENABLE(&TIM_InitStruct);

HAL_DMA_Start_IT(TIM_InitStruct.hdma[TIM_DMA_ID_UPDATE],(uint32_t)&my_buf, (uint32_t)&GPIOA->ODR, 100);

}

But this code did not work. There is no DMA interruption in any way. I must be making a mistake somewhere. Where? 

Any idea? How can I do that?

#gpio #stm32 #timer #dma #data #parallel #transfer
2 REPLIES 2
Posted on June 24, 2018 at 00:22

>> I must be making a mistake somewhere. Where?

TIM3_UP -> DMA1_CH3

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
T J
Lead
Posted on June 24, 2018 at 03:15

that's we we use the cube, it separates the setup faults from the novice.

I couldn't work without the cube.

Like the Touch Sensing system.

what a nightmare,

and yet the hardware is really quite good.

I used the cube to setup the hardware but disabled the optional middleware.

Works like a treat, albeit convoluted