For the statement
var = Register.PortA
Does var get the device port register or the inputs from the device pins?
Thanks
Richard
Port read & write
Re: Port read & write
Register.PortA returns the value last written to Register.PortA. If you want to read the inputs to the pins you must use Register.PinA. That only works, of course, for pins that are configured as inputs. For pins that are outputs the value of the last value written to the corresponding bit in the Port register unless an external driver is forcing the pin to a different state (a situation that should be avoided).rich wrote:Does var get the device port register or the inputs from the device pins?
The attached image, excerpted from an AVR datasheet, illustrates how this works. The Pxn represents an external pin. Above that is the pullup resistor that is enabled by the gate above it. The bottom portion shows the input circuitry while the middle of the right side represents the PORTx latch. The upper right is the data direction control which enables the output driver if the pin is configured to be an output.
- Attachments
-
- AVR_IO.jpg (63.94 KiB) Viewed 3227 times
- Don Kinzer