cancel
Showing results for 
Search instead for 
Did you mean: 

PWM mode and ARPE bit | Confirmations

Zzaaack
Associate III

Hi everyone,

I am dealing with the configuration of a PWM in center-aligned mode in the context of the stm32H755 MCU. Such PWM is managed using TIM1 as "driver". The application requires to change every 100 us (TIM1 period) the ARR register to make it last a little bit longer/shorter at every cycle.

I am running into the issue of updating the ARR register and noticing that while the expected output duty should be 100%, it is not. A very small peak down can be seldomly noticed on the oscilloscope.

As of today, the only solution I have implemented is the check for up-counting and downcounting of TIM1 (100 us + 100 us), updating the ARR register only in down-counting instances, avoiding the peak. But in this case the control running in the background is underperforming, actuating once every 2 hits.

I have found on the datasheet the ARPE bit, for what concerns my application I think it might help in my case but i would love to have some confirmations. Do I avoid the "peak issue" just setting this bit and updating the ARR whenever in the upcounting/downcounting phases? It will be updated at the beginning of the next phase, regardless the counting direction?

Zzaaack_0-1748528362740.png

Thanks very much for the support.

Zack

 

1 ACCEPTED SOLUTION

Accepted Solutions
Sarra.S
ST Employee

Hello @Zzaaack

When the ARPE bit is set, updates to the ARR register are buffered and only take effect at the next update event, so the new ARR value will be applied synchronously with the timer's counting cycle. 

In your case, enabling ARPE will allow you to update the ARR register at any point during the counting cycle (up-counting or down-counting)

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Sarra.S
ST Employee

Hello @Zzaaack

When the ARPE bit is set, updates to the ARR register are buffered and only take effect at the next update event, so the new ARR value will be applied synchronously with the timer's counting cycle. 

In your case, enabling ARPE will allow you to update the ARR register at any point during the counting cycle (up-counting or down-counting)

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Zzaaack
Associate III

Hi @Sarra.S 

Thank you very much for your prompt response!
Let me add a side-question.

If i have the ARPE bit set and set a new ARR value even if the update event is yet to arrive. The ARR value will not be changed before the update event is recalled.

In case i decide to read the ARR value before it is actually actuated, do I get the buffered value or the actual value (let's call it old value)?

Sarra.S
ST Employee

Hello again @Zzaaack

yes, if you read the ARR register while the ARPE bit is set, you will get the buffered value 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.