|
Hi,
I believe this is what you are looking for: in portA , you want some of the pins to act as O/P and some other pins as I/P pins.
SAy, if you want port A.0 to act as O/P and rest of the pins as input, then you can assign:
OEA = 0x01; // only portA.0 is enabled as O/P
Similarly, if you want, say portA.0, 3, 5 as O/P pins, then
OEA = 0x29; //portA.0,3,5 enabled as O/P pins
OEA is the O/P enable register for portA. i.e. by setting the appropriate bit in OEA, the appropriate bit of portA can be configured as O/P.
Whereas, IOA reflects the portA status. If you want to assign any particular value to O/P pin of portA, then assign the particular value to the approriate bit of IOA. Similarly, to read the value at the input pin of portA, you can read it from the appropriate bit of IOA.
Say, if you want to make
- portA.0 as O/P pin and make it high
- PortA.1 as I/P pin and read its status
then
OEA = 0x01; //portA.0 is enabled as O/P pin
IOA |= 0x01; // set portA.0 as high
<VAR> = IOA & 0x02; //read status of portA.1
I believe this is what you are looking for.
Regards,
Gayathri
|