making PORTD as Input/Output PORT.....

Status
Not open for further replies.

jhon caty

Newbie level 3
Joined
May 14, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,304
i am working with PIC18f4550 and using MPLAB C18. I am facing problem in making PORTD as I/O port. plz guide me. THANKS......
 

If you want PORTD to be input port then the code is
Code:
 TRISD = 0xFF;
. If you want PORTD to be output port then the code is
Code:
 TRISD = 0x00;
 

i want to initialize some pins of portD as input as some as output .
 

If you want to intialize RD0, RD1, RD2, RD3 as input and RD4, RD5, RD6, RD7 as output then you do like this

Code:
 TRISD = 0b00001111;
0b tells we are using binary format. 0000 makes RD4-RD7 output. 1111 makes RD0-RD3 as input.

Whichever pin you want as output, you set it 0 and whichever pin you want as input you set it 1.
 
hi jhon caty,
if you use pin as i/p place as '1' , its o/p its place as '0'.
 

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…