> >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. ok, now assuming we have LAT to solve the issue, what do we need to do with LAT register, should be use BSF PORTA,0 or BSF LATA,0 also, am I correct to say that LAT is only important for output pins tia. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist