Quote:
You are using oninterrupt aswell. I think the difference is how i did the timing for the PWM. I didnt use pause at all, instead i used the speed of the loop. The faster the pic chip runs the faster the PWM should run. In theory that should have worked fine. The problem i had is that when serial data arrived it was delaying a few iterations of the loop and causing a flash.
Yep, and I'm doing my PWM in a controlled manner. Basically, I'm doing nothing more than the hardware PWM already does except I'm doing it manually. Manually updating the count, manually doing the compare to either turn on or off the output.
Quote:
'setup all the variables, pins, etc.etc.etc.etc.
'On Interrupt
'checks Tmr0 overflow and updates outputs based on duty cycle registers
'checks Serial RX register and saves value
'Returns from interrupt
'subroutines
'more setup
'main loop
'acts on serial data received to change desired duty cycle registers for individual LEDs
'for example, break the received byte into bits...
'b7-b4 = LED duty cycle to modify (b7=Red,b6=Green,b5=Blue,b4=White)
'b3-b2 = increase/decrease/max/min (b3=increase by x, b2=decrease by x)
'b1-b0 = increase-decrease amount (00=by 1, 01=by 5, 10=double or half depending on b3-b2, 11=max or min depending on b3-b2)
'goto main loop
'on interrupt fires as often as it needs to fire, every time Tmr0 overflows (19.5khz) and/or whenever a data byte is received at the serial port (i.e. 115,200 baud isn't too fast)
So, using this example, you send %11111011, it will:
1111 = bit 7 thru bit 4, all LEDs selected
10 = bit 3 thru bit 2, increase by x
11 = increase values to maximum