Jan-Erik Soderholm wrote: > On 2010-09-22 09:06, David Duffy (AVD) wrote: >> So to be clarify, I don't understand why Microchip are setting LATx >> *and* PORTx during initialisation in their example. Setting PORTx seems >> to be totally redundant in devices that have LATx registers. >> =20 > > Yes, that is redundant. > > B.t.w, *which* datasheet is this ? > I'd like to verify the context this was written in. > =20 PIC16F1934 - document DS41364D > When *writing*, PORTx and LATx are setting the same > internal registers in the PIC (the "output latch"). > So when writing (CLRF, MOVWF...) it doesn't matter if > you use LATx or PORTx, the effect is exactly the same, > the data is written in the "output latch". > =20 That's why I thought it odd that Microchip clear both (effectively the=20 same) in their example. It wouldn't be the first time their examples=20 were not the best. > Note that *ALL* PIC has "output latches", they are just not > directly readable on some PICs (those without LATx registers). > If not, there wouldn't be anyplace for the PIC to "remember" > the value written to the PORT, right ? > =20 Well yes, I was making the distinction that the LATx was a register in=20 the sense that is was accessible. > It's very much the same as the fact that on some (older) > PICs the "working register" ("W") is not mapped as a > "file register". On PIC18 and the newer PIC16F1xxx there > is a mapped "WREG" SFR register that can be used for > BCF/BSF/RRF/RLF or similar instructions that are otherwise > not usable directly against "W". > =20 Ooh, I hadn't noticed that yet. There's been a few times I wished I=20 could rotate operate on W directly. 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 .