> ... and then, later in your code, you mistakenly write: > > BSF PORTA,Relay ;Turn on the relay > or > PORTA.Relay = 1; // Turn on the relay. > > You can eliminate this common source of errors by including the > port name in your #define: > > #define Relay PORTB,0 > or > #define Relay PORTB.0 > > then: > > BSF Relay ;Turn on the relay in assembly. > or > Relay = 1; // Turn on the relay in C. This works fine for addressing the individual port bit, but does not help you if you need to access the whole register containing the bit, or need to use the bit number other than with the port register. A better way it to use my /INBIT and /OUTBIT preprocessor directives. The project include file would contain: /outbit relay porta 0 0 ;relay on when 1, off when 0 This automatically causes a bunch of assembler constants to be defined. Here are some example instructions that could be found in a module using the include file. These are just code snippets not meant to be useful code: dbankif relay_reg ;set banks for access to RELAY port reg bsf relay_pin ;turn on the relay . . bsf shadow, relay_bit ;enable relay in the shadow copy . . dbankif relay_tris bsf relay_tris, relay_bit ;float the relay output pin There is a lot more to the preprocessor. All the details can be found at http://www.embedinc.com/pic/. You can follow the links to download your own copy of all the PIC development tools. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body