At 02:14 PM 2/19/2006 +0000, you wrote: >Hi, >What is this LAT registers, what do they do, something read-modify-write >I completely don't understand this. Why do I need anything else if I have >PORT and TRIS ? Using a RMW instruction on a PORT register (eg. bsf PORTA, 0) will read all the bits in PORTA, set bit 0, then write the bits back again. However, when you use the PORT address, the R part of the RMW reads the levels actually on the port pins, which, for reasons of loading or because the pins have not settled, or because it's an open-drain output, may not be at the same logical levels as the port latch itself. This may vary from part-to-part, with external hardware conditions or asynch timing conditions (was there just an interrupt?). The state of the latch may thus undergo an unintended change (in bits other than 0 in the above example). You may have to have a shadow latch register in RAM and put more instructions in there to get it to work consistently (of course it consumes RAM and runs slower at bit-diddling, which is one thing PICs are pretty good at). Using the LAT address means that R part of the RMW reads from the port *latch*, not the port pins, so RMW instructions work right every time. When introduced, it was LONG overdue, IMHO. Particularly since the 18F series can execute instructions faster than the port pins can reliably change state. Best regards, Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com ->> Inexpensive test equipment & parts http://search.ebay.com/_W0QQsassZspeff -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist