I have a theory! I just added some code to the loop (the working part) to change the value of the red LEDs and its started flickering a little. I belive the problem is in the way ive done the PWM.
The PWM counter starts at 255. Everytime TMR0 overflows it decrements that value then compares it with the value of each LED. If they match then it turns the LED on. When it gets to 0 it resets back to 255 and turns off any LEDs whos value is less than 255. I think that by changing the value sometimes the PWM counter "misses" the LEDs value so it never turns on until the PWM counter resets to 255 and comes around to the new value.
When testing DT's code i think he does it the oposite way. Turn the LEDs on and count up then turn them off when the value matches. When testing that code the LEDs seemed to flash brightly rather than turn off for half a second.
Im gonna try and fix that problem but again i wouldnt have thought missing 1 PWM cycle would affect the LEDs that bad
Bookmarks