cancel
Showing results for 
Search instead for 
Did you mean: 

DAC+DMA stops while loop for 100 seconds

MNajj.1
Associate

Hello everyone,

I am very new in MCU programming and still learning it. I am doing a small project with DAC and Timers2,3 on STM32F429. DAC is trigger by time2 and timer3 is a counter which is triggered by a switch.Also, I have an LED blinking an a data transmit from UART in the while (1) loop. Each peripheral is working well separately , the DAC output is fine (DAC+DMA), the counter counts correctly, and the timer creates trigger for the DAC on time. However, all together, they make an unpredictable result. Still Everything is working but LED. LED blinks for 5 seconds and stops blinking for excatly 100 seconds and then starts blinking again (this means the while loop does not work for 100 seconds). I turned off the USART and DAC, ADC, TIM6 interrupt but the problem is still there. However, when I turn the DAC off (do not start DAC) or remove the UART data transfer the LED works well. It seems that these two conflict each other for a period of 100 sec.

Any help is appreciated. If the full code is required, I can provide it.

HAL_DAC_Init(&hdac);

HAL_DAC_Start_DMA(&hdac,DAC_CHANNEL_1,(unsigned int*)Sine_vec, precision, DAC_ALIGN_12B_R);

HAL_TIM_Base_Start_IT(&htim2);

HAL_TIM_Base_Start_IT(&htim3);

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_1);

HAL_Delay(50);

//count3_sw = __HAL_TIM_GetCounter(&htim3);

strcpy(Message,"");

sprintf(Message,"Switch Counter = %d \r\n",count3_sw);

put_str(Message);

 }

2 REPLIES 2
TDK
Guru

Debug your code and see where it's at during the 100sec timeout. Probably stuck waiting in an interrupt somewhere, maybe a timeout gets hit. Your DMA might be getting overloaded which will trigger an error.

If you feel a post has answered your question, please click "Accept as Solution".
berendi
Principal

My guess:

The message is about 20 characters long, UART examples have 5s timeout. Adjust either the message length or the timeout and see what happens.

Some conflict between the UART code and the interrupt handlers?