Confirm with scope on pins A0, A1, A2, and A3.
All outputs are 50 Hz.
A0 duty cycle is 20%, A1 duty cycle is 40%, A2 duty cycle is 60%, A3 duty cycle is 80%
Modify the A3 line and change the frequency to 10 hz
Use scope on pins A0, A1, A2, and A3 to check frequency and duty cycle.
All outputs are 10 Hz.
A0 duty cycle is 20%, A1 duty cycle is 40%, A2 duty cycle is 60%, A3 duty cycle is 80%
Timer 5 values differ in the PSC registers for each case.
PSC at 10Hz is x6d, PSC at 50Hz is 0x15, converting to decimal give 109 and 21.
109/21 ~= 5
Design consideration:
If you need PWM outputs with different frequencies, you will need to select pins that use different timers for different frequencies.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Experiments with timers:
Experiment 1:
Setup A0 at 50hz, Duty cycle 20%
Setup A1 at 50hz, Duty cycle 40%
Setup A2 at 50hz, Duty cycle 60%
Setup A3 at 50hz, Duty cycle 80%
Using isTimerEnabled3.js modify lines 168..172
Confirm with scope on pins A0, A1, A2, and A3.
All outputs are 50 Hz.
A0 duty cycle is 20%, A1 duty cycle is 40%, A2 duty cycle is 60%, A3 duty cycle is 80%
Modify the A3 line and change the frequency to 10 hz
Use scope on pins A0, A1, A2, and A3 to check frequency and duty cycle.
All outputs are 10 Hz.
A0 duty cycle is 20%, A1 duty cycle is 40%, A2 duty cycle is 60%, A3 duty cycle is 80%
Timer 5 values differ in the PSC registers for each case.
PSC at 10Hz is x6d, PSC at 50Hz is 0x15, converting to decimal give 109 and 21.
109/21 ~= 5
Design consideration:
If you need PWM outputs with different frequencies, you will need to select pins that use different timers for different frequencies.