- Sun Jan 06, 2008 2:44 am
#40476
I have a good feeling my little blips of brightness are coming from the fact that the timer interupts the update code multiple times. I've managed to get the blips to all sync up by making sure the timer never updates the shift register while the main code is updating the data.
After looking at the math and the generated code, I've realized that my timer code is way to large. The timer is set to go off after about 390 instruction cycles, each time. And I'm pretty sure the timer code itself is longer than that after its all done updating all 8 bits of the shift register.
I can tell you one thing, even in release extended instruction mode, the code C18 generates seems to be a little verbose.
So far I've implemented my software PWM in two parts, the pwm code itself it run from a timer interupt every MCU_IPS/PWM_PERIOD (390) instruction cycles (timer ticks). And the main() loop updates the pwm data on a delay.
What would be the recommended way of doing this? The way I've come up with isn't working as well as I'd hope. Does anyone here have any recommendations?
After looking at the math and the generated code, I've realized that my timer code is way to large. The timer is set to go off after about 390 instruction cycles, each time. And I'm pretty sure the timer code itself is longer than that after its all done updating all 8 bits of the shift register.
I can tell you one thing, even in release extended instruction mode, the code C18 generates seems to be a little verbose.
So far I've implemented my software PWM in two parts, the pwm code itself it run from a timer interupt every MCU_IPS/PWM_PERIOD (390) instruction cycles (timer ticks). And the main() loop updates the pwm data on a delay.
What would be the recommended way of doing this? The way I've come up with isn't working as well as I'd hope. Does anyone here have any recommendations?
Thomas Fjellstrom