Skip to main content
arjun.binu
Associate III
Feb 15, 2023 2:49 AM UTC
Question

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

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.

This topic has been closed for replies.

11 replies

Javier1
Principal
Feb 15, 2023 8:20 AM UTC

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.

hit me up in https://www.linkedin.com/in/javiermuñoz/
arjun.binu
Associate III
Feb 15, 2023 8:31 AM UTC

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?

Javier1
Principal
Feb 15, 2023 9:26 AM UTC

>>to be triggered sequentially

what do you mean with sequentially?

hit me up in https://www.linkedin.com/in/javiermuñoz/
Javier1
Principal
Feb 15, 2023 9:36 AM UTC

This is how you set the TIM1 pwm0693W00000YAmH6QAL.png 

This is how you set the adc

0693W00000YAmFkQAL.png

hit me up in https://www.linkedin.com/in/javiermuñoz/
arjun.binu
Associate III
Feb 15, 2023 11:27 AM UTC

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.

Javier1
Principal
Feb 15, 2023 2:18 PM UTC

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

hit me up in https://www.linkedin.com/in/javiermuñoz/
arjun.binu
Associate III
Feb 16, 2023 3:59 AM UTC

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