2024-03-12 02:39 AM - edited 2024-03-12 05:48 AM
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.)
Thanks!
Solved! Go to Solution.
2024-03-12 06:24 AM - edited 2024-03-12 06:25 AM
> 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:
and here:
2024-03-12 05:17 AM
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.
2024-03-12 06:00 AM
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
2024-03-12 06:24 AM - edited 2024-03-12 06:25 AM
> 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:
and here: