qmk / qmk_firmware

Open-source keyboard firmware for Atmel AVR and Arm USB families
https://qmk.fm
GNU General Public License v2.0
18.08k stars 38.86k forks source link

Is it possible to have a second hardware PWM pin with its own controls? #7546

Closed HMarxen closed 2 years ago

HMarxen commented 4 years ago

Hi, I would like to add a TLC6C598PWR IC to my design which is a shift register with a seven-segment display driver. The IC has an enable pin which allows to PWM the segment display. So, it would be fantastic if I could set an independent brightness for the display. On the 32u4 I would hook the key backlight to the timer 1 and the segment display to timer 3. If this is theoretically possible, this would also be a feature request. I don’t think I could contribute the code myself. :-/

HMarxen commented 4 years ago

With a second hardware PWM you could also put a transistor to the common cathode of the num lock, scroll lock and caps lock LEDs and adjust their brightness independently. Or you could try other cool stuff like using an analogue 5 volt meter as a keystroke per minute gauge. The faster you type the more goes the physical needle into the red.

drashna commented 4 years ago

Do you mean for the STM32 chips?

HMarxen commented 4 years ago

No the Atmega32u4. Would this be easier to do on a STM32?

HMarxen commented 4 years ago

Anyone?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed in the next 30 days unless it is tagged properly or other activity occurs. For maintainers: Please label with bug, in progress, on hold, discussion or to do to prevent the issue from being re-flagged.

noroadsleft commented 4 years ago

I'm neither a hardware guy nor a programmer, so take this with a grain of salt, but:

32U4 seems to have four PWM channels. On those chips, I believe Backlight uses one channel and Audio uses a second, which leaves two channels unused. Seems the limitation is writing the supporting programming.

sigprof commented 4 years ago

More precisely, ATmega32U4 has 4 timers; however, Timer0 has only 8 bits and is used as the system timer, and Timer4 is a special “high speed timer” (it is 10 bit with a possibilty of using 11 bit resolution for PWM). The current backlight code is able to use only Timer1 and Timer3, which are 16 bit timers; however, each timer output can be connected to a limited set of pins. It could be possible to use a single timer for up to 3 PWM signals (which will have the same frequency, but different duty cycles), but only if the LEDs are connected to specific pins.

Pins that are usable for PWM are:

With the current code only B7, B6, B5, C6 pins are supported; using B7+B6+B5 at the same time could be possible with just one timer.

zvecr commented 2 years ago

This issue has been automatically closed because it has not had any recent activity. If this issue is still valid, re-open the issue and let us know.