Input Output Sharing Same Port

Status
Not open for further replies.

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Hi,

I'm using uC controlling the multiplexer. P1^0...P1^2 is control addressing multiplexer and the P1^7 is get the result from multiplexer.

Is it possible to do that? How am i to write the code?

Please advice.

Thank You.
 

AA,
Yes you can do this.
here are the codes the code
; making P1.0 ... P1.2 work as an input
SETB P1.0;
SETB P1.1;
SETB P1.2;

;Writing to these bits:
MOV A, #value
MOV P1, A

;Reading from P1.7
MOV C, P1.7

BR,
Amr Ali.
 

Hi,

I'm not so familiar with assembly language. :|

I had slightly your an assemble to C.
Code:
sbit PB0 = P1^0;
sbit PB1 = P1^1;
sbit PB2 = P1^2;

sbit PB7 = P1^7;

void main()
{
	bit rst;

 	while(1)
	{
		PB0 = 1;
		PB1 = 0;
		PB2 = 1;

		rst = PB7;
	}
}
Do you mean that?

Actually i wish to structure the port IO. ex. P1^0...P1^3 is output and P1^4...P1^7 is input.
Perhap using Bit Field mothed.
Code:
struct IO{ 
     unsigned char OLSB:4;   // P1^0...P1^3
     unsigned char IMSB:4; // P1^4...P1^7
}
My idea is like this.
Once i assign the OLSB=3; the output port for P1^0...P1^3 result will be 1100.
So for the IMSB is ready to read the data from the port.

Code:
OLSB=3;     // control output bit 
rst = IMSB; // receive result from the port.

Is it possible to do that?

Thank You.
 

in 8051 u can take input and output from any pin

Remember for Inputs u have set those pins
 

ashad said:
in 8051 u can take input and output from any pin

Remember for Inputs u have set those pins
Thank for your remind. I understand about it.
How am i to do that? Please advice.

Thank You.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…