PIC I/O...

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

PIC I/O...

Postby syntium87 » Fri May 06, 2011 3:20 pm

i'm using pic16f877a and mplab to program the pic....
i got this problem..how to set one of the pic port to become input and output together..?(like set a pic port pin that can be input and output)..
can it be done??
wht should i write on the c program??? help pls...
syntium87
Novice
 
Posts: 27
Joined: Sun Apr 03, 2011 12:51 am

Re: PIC I/O...

Postby Brian Griffin » Fri May 06, 2011 3:48 pm

syntium87 WROTE:i'm using pic16f877a and mplab to program the pic....
i got this problem..how to set one of the pic port to become input and output together..?(like set a pic port pin that can be input and output)..
can it be done??
wht should i write on the c program??? help pls...


You cannot make the port pin to become input and output together. But however, you can turn it into an output or an input one at the time.

Input : TRISX.RY = 1
Output: TRISX.RY = 0

(X denotes the Port, and Y denotes the pin number/bit)

Hope that helps.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: PIC I/O...

Postby syntium87 » Fri May 06, 2011 3:58 pm

so,it means that i cannot set it as a bidirectional(input and output) pin port?

i just read this data from microchip website...
http://www.microchip.com/forums/tm.aspx?m=147534&mpage=1&key=PORT,PROBLEM,16F870&

chapter 9 i/o considerations --> bidirectional port


it said in can be set..but i dont know how to write the code in c..help me...
syntium87
Novice
 
Posts: 27
Joined: Sun Apr 03, 2011 12:51 am

Re: PIC I/O...

Postby syntium87 » Fri May 06, 2011 4:11 pm

sorry...wrong link...
this is the microchip website link

http://ww1.microchip.com/downloads/en/devicedoc/31009a.pdf

can such operation being used on pic16f877a?
c code??? :?
syntium87
Novice
 
Posts: 27
Joined: Sun Apr 03, 2011 12:51 am

Re: PIC I/O...

Postby yonghui » Fri May 06, 2011 8:17 pm

Hi,
most PIC ports are bi-directional digital input output pins, but there is no need for bidirectional at one time.
set it to input when we need it as input, and set it to output when we need it as output. we can switch it as input or output very fast.
only some port pins are unidirectional, one example is the port pin which share with master clear, MCLR pin which can only be set to digital input.

regards,
yh
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: PIC I/O...

Postby Brian Griffin » Fri May 06, 2011 8:42 pm

I haven't heard of an I/O pin can become an input and an output at the same time. Normally, it's one at the time.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 6 guests