2023-02-14 06:49 PM
The following article helped us to use timers to trigger ADC conversions periodically. We now require to trigger ADC conversions at the centre of PWM pulse to get an accurate readings from ADC channels. Please help us with a solution to use center aligned mode associated with Timer 1. Your assistance and backing are much appreciated.
2023-02-15 12:20 AM
Hi @arjun.binu , you want the ADC to be triggered when the TIM1 update event happens.
In PWM center aligned mode , the update of TIM1 (when the counter rollsover) happpens right in the middle of the PWM.
Tell me which specific STM32G030x are you tring to use and which ADC TIM pins.
2023-02-15 12:31 AM
We are using STM32G030F6P6. We require ADC channels to be triggered sequentially by update event of Timer.
We tried to configure center aligned PWM mode by
1) Setting PWM generation channel mode to PWM Mode 2 (We also tried with Mode 1)
2) Setting Counter mode to Center aligned mode 1
Could you please let us know how we can properly configure center aligned PWM mode with TIM1?
2023-02-15 01:26 AM
>>to be triggered sequentially
what do you mean with sequentially?
2023-02-15 01:36 AM
This is how you set the TIM1 pwm
This is how you set the adc
2023-02-15 03:27 AM
We will try this out and update you soon.
By sequentially we meant the sequential conversion of 3 ADC channels we are using. But I guess this particular information may not be much relevant.
2023-02-15 06:18 AM
I dont think "sequential" means what you think.
The ADCs will be triggered at the same time, then "sequentially" stored in memory by your code or the DMA
2023-02-15 07:59 PM
Okay. I understood. I'm actually new to microcontrollers.
2023-02-15 08:21 PM
@Javier Muñoz I have tried out the above configurations.
Attaching the report generated from .ioc for your reference.
If I set CCR2 by directly writing to register like TIM1->CCR2 = 30, then I'm getting a PWM pulse of duty cycle 85.
I'm not able to properly confirm if it is center aligned PWM.
I would like to generate a center aligned similiar to the one shown below:
2023-02-16 06:19 PM
@Javier Muñoz
Is it possible to generate an edge aligned PWM and a center aligned PWM no output from a single timer (TIM1)?