Yep, your way looks like the way DT's code did it. You turn everything on then count up and turn each LED off as the counter reaches the PWM value. In my code i turn them all off then count down and turn them on when the counter reaches the PWM value.
I think i probably did it that way because my previous PWM circuits controlled AC lights through a triac. The way you and DT did it would still work and probably be better for AC lights but it needs those other components similar to triacs (cant remember the name) and they are more expensive.
Ive uploaded the file so you can take a look. I know theres lots of bits that seem pointless at the moment. Ive got to addin all the other stuff that i had before.
BTW, that still gets serial data in the main loop. I may still need to buffer it in an interrupt once i have all that extra code back in but for now it works and it doesnt need to buffer all the data that arrives.
Edit: I commented out the bit that resets the serial flag. When i was having trouble i thought maybe that changing PIR1.5 was causing another interrupt or something but it turns out that it works without it. Reading RCREG seems to clear it anyway so is that really needed?
Edit2: Ive uploaded a newer version of the code. I used your buffer idea for sending serial data. Not sure if it works because i dont have the PIC here to test it. All i know is that it compiles properly. I still need to figure out how to set the stored address. That will be a tough one
Bookmarks