cancel
Showing results for 
Search instead for 
Did you mean: 

STM32u575 GPIO and DAC output using a timer triggered DMA

eosella
Associate II

Hi everyone

I'm trying to get involed with the nulceo STM32u575 board developing an application that should perform synchronously a GPIOB pins output configurations over time (periodic) and set a specific analog value to each GPIO pins, So ideally I'd have two arrays, one for the DAC and the second for the GPIO, and a Timer instance that triggers the GPIO pattern and sets the DAC output value. I was considering performing this using a couple of Timer triggered instances, one for the GPIO and the other for the DAC.

 

By now, I started with the GPIO stuffs, and I'm able to configure the timer (checking the callback function), but I'm not getting the GPIO ouputs...

In the main function:

/* USER CODE BEGIN 2 */
uint32_t gpiovals[it_max] = {PB0_Pin | PB1_Pin, PB1_Pin | PB2_Pin, PB2_Pin | PB4_Pin, PB2_Pin | PB4_Pin, PB4_Pin, PB0_Pin , PB1_Pin, PB2_Pin};

TIM2->DIER |= (1<<8);// set UDE bit (update DMA request enable)
__HAL_TIM_ENABLE_DMA(&htim2, TIM_DMA_TRIGGER);
HAL_DMA_Start_IT(&handle_GPDMA1_Channel10, (uint32_t)gpiovals, (uint32_t)&(GPIOB->BSRR), it_max);
HAL_TIM_Base_Start_IT(&htim2);

/* USER CODE END 2 */

And attached, I left the ioc file. Any help will be appreciated!

 

Thanks in advance

2 REPLIES 2
markmills
Associate II

seems like the GPIO pins may not be properly initialized as output. ensure your DMA is correctly configured to transfer values to the GPIOB BSRR register. Double-check the DMA stream/channel and transfer direction are set for GPIO operations. Also, confirm the timer is correctly triggering the DMA. Using STM32CubeMX might help visualize and confirm the correct configuration.

Hi @markmills  and thanks for your reply. 

All the three (timer, GPDMA, and GPIOs) are configured using the device configuration tool in the stm32CubeIDE, and the initialization were delivered without additional modifications.

Now I've added a the extl line 13 for the GPIOs interruptions but without any change.

I understand that transfer values are configured in

 

 HAL_DMA_Start(&handle_GPDMA1_Channel10, (uint32_t)gpiovals, (uint32_t)&(GPIOB->BSRR), it_max);

 

and the direction is configured as memory to peripheral.

I don't know how to specifically check wether the timer is triggering the DMA, but I've checked that the timer is running, by implementing the callback function:

 

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
	static uint16_t iter=0;
	iter= (iter+1)%it_max;
	if(htim->Instance == TIM2)
	{
		HAL_GPIO_TogglePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin);
		HAL_GPIO_TogglePin(GPIOB, PB0_Pin); // this was used to check if the GPIO pin was well configured

	}
}

 

 

I've attached the IOC file again.

Any additional help will be appreciated :)