On 22/09/2010 3:16 PM, Scott wrote: >> Up until now, I've only used the older (lower end?) PICs > 16F and lower don't have LAT. You might want to check that. I'm using a 16F1934 and it does indeed=20 have LATx registers - 5 of them! >> I think I understand the difference between PORTx and LATx, but in one >> data sheet Microchip show port B being initialised like so: >> >> BANKSEL PORTB >> CLRF PORTB >> BANKSEL LATB >> CLRF LATB >> BANKSEL ANSELB >> CLRF ANSELB >> BANKSEL TRISB >> CLRF TRISB >> >> Why bother clearing TRISB when you would be only writing to LATB anyway? >> David... > TRIS controls the direction of the pin (e.g. input or output). > Use PORT when you want to read a digital input. > Use LAT when you want to write a digital output. > Yes, I understand this. But why bother clearing PORTx when clearing=20 LATx is really clearing the port? Reading PORTx will give the actual pin level, but it seems redundant to=20 write to PORTx when LATx is available. About the only reason to write to PORTx (when LATx is available) is=20 where you want the actual pin levels to be taken into account due to the=20 RMW operation. I really can't think of a real application for this though. David... --=20 ___________________________________________ David Duffy Audio Visual Devices P/L Unit 8, 10 Hook St, Capalaba 4157 Australia Ph: +61 7 38235717 Fax: +61 7 38234717 Our Web Site: www.audiovisualdevices.com.au ___________________________________________ --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .