cancel
Showing results for 
Search instead for 
Did you mean: 

How to use center aligned PWM mode associated with Timer 1 in STM32G030x?

arjun.binu
Associate III

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.

11 REPLIES 11
Javier1
Principal

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.

we dont need to firmware by ourselves, lets talk
arjun.binu
Associate III

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?

>>to be triggered sequentially

what do you mean with sequentially?

we dont need to firmware by ourselves, lets talk

This is how you set the TIM1 pwm0693W00000YAmH6QAL.png 

This is how you set the adc

0693W00000YAmFkQAL.png

we dont need to firmware by ourselves, lets talk
arjun.binu
Associate III

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.

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

we dont need to firmware by ourselves, lets talk

Okay. I understood. I'm actually new to microcontrollers.

@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:

0693W00000YArefQAD.png

@Javier Muñoz​ 

Is it possible to generate an edge aligned PWM and a center aligned PWM no output from a single timer (TIM1)?