cancel
Showing results for 
Search instead for 
Did you mean: 

PWM register of TIMER

luke514
Senior

I have initialized a project with STM32CubeIDE (the .ioc file) using the STM32F407G discovery.

I want to produce on an output pin of the TIMER4 a PWM signal with a certain duty cycle, so I set in the .ioc file the various parameters and in particular the "Pulse" parameter which, if I am not wrong, takes values in the range [0 .. ARR]. The value 0 corresponds to 0% Duty Cycle while the value ARR corresponds to 100% Duty Cycle. Is this correct?

 

Since I want to be able to change the pulse parameter dynamically without having to set it every time by opening the .ioc file ... I decided in the main.c to directly change the register responsible for the Pulse parameter. So in the Reference Manual I looked up what it was and I found "one pulse mode" (in the attached reference manual, see section 18.3.10). I have read it several times but I can't figure out which register stores the Pulse value of TIMER4.

I found out "indirectly" that it's CCR3 register because, during the simulation/debug, in the SFRs section I saw that in CCR3 there was a decimal value equal to the one set in "Pulse" in the .ioc file

Can you help me understand that CCR3 is the Pulse register only by using the documentation? (datasheet, reference manual, etc.)

 

luke514_0-1710235862441.png

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> Is this correct?

Yes.

> Can you help me understand that CCR3 is the Pulse register only by using the documentation? (datasheet, reference manual, etc.)

It's not written as "pulse" anywhere in the reference manual except in the OPM section since it is a single pulse there. That is an STM32CubeMX term (same with Period).

The RM says you can modify CCRx to adjust the waveform in a number of areas. For example, here:

TDK_0-1710249822529.png

and here:

TDK_1-1710249928496.png

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

3 REPLIES 3
gbm
Lead III

Check which timer channel (output) is used in your application. CCx controls TIMyCHx output, so if you use Channel 3 - CCR3 is the right register to set the pulse width.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

Thanks for your reply.

"CCx controls TIMyCHx output" where is this written?

I am using CH3 so it is CCR3, logically I thought so too, however I would like to find it written in the reference manual

TDK
Guru

> Is this correct?

Yes.

> Can you help me understand that CCR3 is the Pulse register only by using the documentation? (datasheet, reference manual, etc.)

It's not written as "pulse" anywhere in the reference manual except in the OPM section since it is a single pulse there. That is an STM32CubeMX term (same with Period).

The RM says you can modify CCRx to adjust the waveform in a number of areas. For example, here:

TDK_0-1710249822529.png

and here:

TDK_1-1710249928496.png

 

If you feel a post has answered your question, please click "Accept as Solution".