‎2022-02-11 02:11 AM
Hi everyone.
I am using STM32G431F4P MCU. I am using Timer3-Channel3 PWM output. PWM frequency is 20 kHz. ADC1 is DMA mode and i want to trigger ADC1 using Timer3-Channel1 (PWM generation no output). Timer3 and ADC1 settings are as follows;
This is code;
HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_3);
TIM3->CCR1 = TIM3->CCR3 = 1000;
HAL_Delay(100);
HAL_ADC_Start_DMA (&hadc1, (uint32_t*)&ADC1_value, 2);
But ADC1 is not triggered. It is only working one time (as soon as i start the ADC1). What is the problem?
Have a nice work.
Solved! Go to Solution.
‎2022-02-14 10:19 PM
Ok guys, i fixed. Problem is DMA settings. I changed the "DMA mode" and "Data width". Now it is working. Thanks for your help.
Have a nice day.
‎2022-02-11 05:36 AM
G0 or G4, typo?
You set Pulse=0, is there a pulse at all? Might try a higher value.
hth
KnarfB
‎2022-02-11 05:58 AM
Sorry mate, my mistake i am using G0, not G4. I guess the problem is not ADC not triggering but DMA not working. I changed the trigger of the ADC1. I am currently using software trigger. I am reading current and voltage from inputs 0 and 2 of ADC1. I am doing PID in interrupt routine by reading these channels with DMA. DMA is not working properly right now. Program goes to the interrupt routine but I can only get the value of one of the channels (ADC1-IN0). Program is so simple;
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_Delay(1000);
HAL_ADC_Start_DMA (&hadc1, (uint32_t*)&ADC1_value, 2);
}
/* USER CODE END 3 */
}
‎2022-02-11 06:18 AM
Ok, i solved the DMA problem. I'm starting the ADC from software and calculate new PID value in DMA interrupt. Now we are back to where we started. I can't trigger the ADC from the timer3.:grinning_face_with_sweat:
‎2022-02-11 11:02 AM
Did you fix the pulse=0 issue? Why use OC1REF at all? Using the update event is more straightforward.
‎2022-02-14 09:49 PM
Hi TDK. pulse=1000 didn't fix the problem. I am using OCREf because i want to read current and voltage feedbacks at the point i want. Also, update event didnt work. :expressionless_face:
ADC is working. ADC==>DR register is changing.I am seeing in system viewer window. But DMA interrupt is not working. I added breakpoint in interrupt routine. Program is not coming to this routine.
‎2022-02-14 10:19 PM
Ok guys, i fixed. Problem is DMA settings. I changed the "DMA mode" and "Data width". Now it is working. Thanks for your help.
Have a nice day.