- PWM Control
100 Tim3_Presc 1 72000 719 Only used if CP Spoof and GS450h Oil pump output is not used
101 Tim3_Period 1 100000 7200 Only used if CP Spoof and GS450h Oil pump output is not used
102 Tim3_1_OC 1 100000 3600 Only used if CP Spoof and GS450h Oil pump output is not used
103 Tim3_2_OC 1 100000 3600 Only used if CP Spoof and GS450h Oil pump output is not used
104 Tim3_3_OC 1 100000 3600 Only used if CP Spoof and GS450h Oil pump output is not used
Soo after some searching this was closest to an explanation I was able to find, but really left me wondering.
Dug through some STM32 application notes (AN4019, AN4776) and stared at Zombieverter source code and maybe I got thisroyhen99 wrote: ↑Thu Jan 30, 2025 10:18 pm Really easy to get the correct frequency. The clock is 72MHz so need total division of 36000000, e.g. 9000 x 4000.
set Tim3_Presc to 8999, and Tim3_Period to 3999. Duty cycle is controlled with Tim3_x_OC, where x is 1 to 3. 1000 gives 25% duty cycle, 2000 gives 50%, 3000 75% etc.

So If I understand it correctly, this royhen99 example is setting a 2Hz update period for Tesla pump, correct?
Looking at the application notes got me thinking about how to go through this so it would be understandable.
We want to have 2Hz PWM frequency, which can be used to calculate the needed params TIM3_Presc and Tim3_Period
- Prescaler is used to set counter clock frequency, this is arbitrary, but you'll probably want the counter to run at kHz level say 100kHz.
System core clock for STM32 used in Zombieverter is 72MHz
Tim3_presc = (System core clock/counter frequency)-1 --> (72 000 000 / 100 000)-1 = 719
- PWM Period can now be calculated
Tim3_Period = (Counter frequency / PWM period)-1 --> (100 000/ 2)-1 = 49999
- Now we can decide the duty % and apply. Lets try 30%
Tim3_X_OC = duty % * PWM period --> 0,3* 50 000 = 15000
- The the duty % adjustment for PWM outputs work if they aren't assigned for another use (i.e. CP spoof)
Tim3_1_OC = duty % on PWM 1
Tim3_2_OC = duty % on PWM 2
Tim3_3_OC = duty % on PWM 3
Did I get this right?
