Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Microcontroller - Same pin is use as input and output

Status
Not open for further replies.

engmunir

Member level 1
Joined
Sep 24, 2007
Messages
38
Helped
7
Reputation
14
Reaction score
8
Trophy points
1,288
Activity points
1,535
Dear Experts
I want to use one pin as input and output. My application is that I want to pullup same pin by using software command bit_set(PORTA,2) and the same pin I want to use as switch input. I mean initially the software will pullup PORTA,2 by using software command. From hardware side i have connected transistor collector which is switching Zero Logic on PORTA,2. I am sensing that Zero Logic in my program. Actually I do not want to use external pullup on PORTA,2. I want to use software pullup on PORTA,2. How can I solve this problem ?
 

If I understand you, the solution is to add a resistor in series with the pin to prevent the transistor sinking too much current then set the pin high in software. You can't tell the pin to go high then read it to see if if managed to do it though. It looks like you are using a PIC but you haven't said which type, you can do this if the pin has an internal pull-up but not all PICs do on PORTA.

You can do this if you can use another PIC pin as well, use PORTA.2 as before but use say PORTA,3 to read the input, connect a resistor between them and the transistor to PORTA,3. This lets you control the pull up with bit 2 and see if it was sucessful with bit 3.

Brian.
 

don't forget that any pin (well, mostly anyone) could be both Input and output... you set this with the TRISA register...
but you need to protect your pin with a resistor like @betwixt mentioned...

If you could post more information (pic used, actual circuit and intented input/output hardware setup)

Additionally there were some PICs (and most AVRs do) that you could setup the PIN as input, and the output register is used as a pull-up controller... sadly not any PIC has this behavior...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top