I was thinking something along those lines as well, but reduce the probability of an error so it's less frequent and seemingly more random: #define if(x) T0CON |=3D 0x80; if ((x) & (TMR0L & 0xF)) Would only have a 1 in 16 chance of affecting the if. It wouldn't mess up the timer unless they were turning the timer on and off inside the program (usually it's either on or off for the entire program, if it's off then they probably arent' using it, and if it's on our statement doesn't affect that). Could go downhill from here, but of course the more we change each if statement, the easier it'll be to see there's a big problem when someone examines the compiler output. -Adam On Tue, Aug 25, 2009 at 9:18 AM, Philip Pemberton wr= ote: > Mark Rages wrote: >> go for random failure: >> >> #define if(x) =A0if ((x) & PORTA) > > Or for even more fun, drive it off of TMR0: > > #define if(x) T0CON ^=3D 0x80; if ((x) & TMR0L) > > Or even: > #define if(x) T0CON ^=3D 0x80; if ((x) & (TMR0L =3D=3D TMR0H)) > > Which toggles the timer on-state every time an 'if' statement rolls > around. I'd file this under "absolutely evil" -- if the code makes use > of TMR0 it's going to completely screw up the timing, if it doesn't... > well... good luck figuring out what's going on, especially if TMR0L > wasn't initialised to a defined value on boot (most 18Fs clear TMR0H to > zero on any reset, but it's undefined on wakeup from SLEEP; TMR0L is > undefined at any reset or wakeup). > > -- > Phil. > piclist@philpem.me.uk > http://www.philpem.me.uk/ > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist