diff options
author | Brice Figureau <brice@daysofwonder.com> | 2019-04-22 11:34:13 -0400 |
---|---|---|
committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-04-22 08:34:13 -0700 |
commit | b61baf4281bde34bfe28aaa1109bd5d5c6471116 (patch) | |
tree | fa60f457b48bbb4d635b32f5b48b03a7dd0dccf7 /keyboards/converter/usb_usb/ble/README.md | |
parent | c28a4321123131b6ff1e6c6b302fba764255623b (diff) |
Fix #3566 use an hardware timer for software PWM stability (#3615)
With my XD60, I noticed that when typing the backlight was flickering.
The XD60 doesn't have the backlight wired to a hardware PWM pin.
I assumed it was a timing issue in the matrix scan that made the PWM
lit the LED a bit too longer. I verified it because the more keys that
were pressed, the more lighting I observed.
This patch makes the software PWM be called during CPU interruptions.
It works almost like the hardware PWM, except instead of using
the CPU waveform generation, the CPU will fire interruption
when the LEDs need be turned on or off.
Using the same timer system as for hardware PWM, when the counter
will reach OCRxx (the current backlight level), an Output Compare
match interrupt will be fired and we'll turn the LEDs off.
When the counter reaches its maximum value, an overflow interrupt
will be triggered in which we turn the LEDs on.
This way we replicate the hardware backlight PWM duty cycle.
This gives a better time stability of the PWM computation than pure
software PWM, leading to a flicker free backlight.
Since this is reusing the hardware PWM code, software PWM also supports
backlight breathing.
Note that if timer1 is used for audio, backlight will use timer3, and if
timer3 is used for audio backlight will use timer1.
If both timers are used for audio, then this feature is disabled and we
revert to the matrix scan based PWM computation.
Signed-off-by: Brice Figureau <brice@daysofwonder.com>
Diffstat (limited to 'keyboards/converter/usb_usb/ble/README.md')
0 files changed, 0 insertions, 0 deletions