enpassant wrote: > > I'm a new PIC user... > To eliminate any ambiguous bits lurking in RAM, Status, Condition etc... > I've been advised to come up with a generic piece of code to add to the > beginning of each program. Does anyone have a standard piece of code > they routinely use to do just this? > Thanks. You have to write these for the exact chip you're working on, and usually for the exact application. It's not too hard, just sit down with the data book, and load a value into every register that controls things. The data books will tell you what to load to enable/disable variuos functions. Sometimes the order you load them in is important, but AFAIK, the pic family dosen't have that problem. Generically, Turn off interrupts, allocate stack, set I/O bits to proper ins and outs, pullups, and initial states, then configure and load timers, and at the last, load initial values into registers and ram locations that the program needs. I always put a routine in to write all of ram to zeros, just before loading ram variables, so that I <> where everything starts from. Makes debugging easier too.