Heres another one. When using Microchips template and header files, check the settings carefully. It took me hours to figure out that the watchdog timer was enabled! I looked through the file and checked some things, but I wasnt thorough, and assumed everything was set in a benign mode. I still dont know why they would default to WTD on. Don Michael Park wrote: > > To me, one of the most confusing aspects of PIC programming is the > conditional testing; i.e., the btfsc and btfss instructions. For > whatever reason, I have trouble choosing the right one, and perhaps some > other newbies have similar difficulties. > > Basically, my problem is that I find the "If some condition, skip next > instruction" model unnatural. Maybe it's all those years using HP > programmable calculators, but I much prefer "If some condition, execute > next instruction, else skip it." So I use a macro to "rename" btfsc to > ifset, and btfss to ifclr. Note the inverted polarity: "Skip if bit > CLEAR" becomes "If bit SET." Now I can write code that looks like an > if/then statement: > > ifclr STATUS,C > goto nocarry > or > ifset PORTA,0 > comf xyz > > The indentation is optional, but I like to emphasize the if/then > relationship. As far as I'm concerned, this is much easier to > write--and read--than code using btfs_. > > The macro definitions are trivial: > > ifset macro f,b > btfsc f,b > endm > > ifclr macro f,b > btfss f,b > endm > > One could easily add special-case tests for zero, carry, etc., but I > haven't found it necessary. I don't have a problem specifying the bit > to test; it's the branching logic that confuses me, and these macros > solve that problem for me. > > HTH. FWIW. YMMV. > > -- > Michael Park > http://www.seattlerocketworks.com/