Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
It corrects a bit of a bug with using the PORTx register. The problem arises from the fact that a read from an output port using PORTx reads the actual logic levels on the pins themselves. So if you have an open drain pin that is driven low by external logic but the open drain transistor is turned off (Should be high but is low) and you use the MOVLW 0xFF and XORWF PORTx, F instructions to toggle the open drain transistor, then nothing will happen. Using the LATx register double buffers the io operation so that read/modify/write instructions work properly by reading from an internal register and not the logic level on the pin.
The same issue can happen on ports with a mix of inputs and outputs where one or more pins are switched from input to outputs and back again and read/modify/write instructions are used on these ports.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.