You are so right !
The thing is however, i have tmr1 setup as a counter and i use its overflow to sync the whole program on 100hz.
I have three different led's that are driven by fet's. Each led has it's own channel and due to the design of the driver, at a given moment only 1 led me be high.
To be able to shift the colors around, i turn on a certain channel for a certain ammount of time.
Code:
RED con %001
GRN con %010
BLU con %100
loop60
if ledred = 0 then goto noRED
GPIO = red
pauseus ledred
noRED:
if ledgrn = 0 then goto noGRN
GPIO = grn
pauseus ledgrn
noGRN:
if ledblu = 0 then goto noBLU
GPIO = blu
pauseus ledblu
noBLU:
goto loop60
Once interrupted the ledred / ledgrn / ledblu values are altered, but always in a way that ledred+ ledgrn + ledblu = 1000, the timer get's a reset and it then jumps back into the loop.
The example above works but pauseus can't delay faster then 12us ...
Bookmarks