Shop OBEX P1 Docs P2 Docs Learn Events
Background PWM on SX28 using minimal cycles (0.6%) — Parallax Forums

Background PWM on SX28 using minimal cycles (0.6%)

BeanBean Posts: 8,129
edited 2007-09-17 23:39 in General Discussion
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

Comments

  • PLJackPLJack Posts: 398
    edited 2007-09-17 23:39
    I'm all over that. Saved.
    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.
Sign In or Register to comment.