Background PWM on SX28 using minimal cycles (0.6%)

I thought I would share my code to create a 1KHz background PWM signal on the SX28 using the internal 4MHz clock and using the bare minimum of cycles.
Here is what I came up with. The interrupt is only called twice for each PWM cycle (to toggle the pin). According to SX-Sim the interrupt uses 12 cycles. It is called 2000 times a second, so that is 24_000 cycles per second of the 4_000_000 cycles. Comes out to 0.6%
Enjoy,
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I know what I know, don't confuse me with the facts...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
Here is what I came up with. The interrupt is only called twice for each PWM cycle (to toggle the pin). According to SX-Sim the interrupt uses 12 cycles. It is called 2000 times a second, so that is 24_000 cycles per second of the 4_000_000 cycles. Comes out to 0.6%
Enjoy,
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I know what I know, don't confuse me with the facts...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
Comments
I have to try it out on my new RGB LEDs.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - PLJack - - -
Perfection in design is not achieved when there is nothing left to add.
It is achieved when there is nothing left to take away.