Continue to Site

Welcome to

Welcome to our site! 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.

How to define BiDirectional i/o pins for PIC Microntroller ?

Not open for further replies.


Full Member level 5
Sep 21, 2010
Reaction score
Trophy points
Activity points
Hello guys,

i am using 16F628A for Multiplexing 7 Segment display. So my Port A has only 4 pins used. Now i want to use two pins for SCL/SDA (soft i2c)

i want to use soft i2c connection and that is where i m stucked. If i define TRISA = 0 (means all pins are set for output) then how can i define

sbit Soft_I2C_Scl at RA6_bit;
sbit Soft_I2C_Sda at RA7_bit;

because i think in serial i2c is m confused...because 16F628A has no hardware i2c.

but how is it possible ? As we have already define TRISA = 0 (means all pins on PortA is output) then how it will works as input/out bidirectional ?

please help m really confused..about how to define any pin on pic microcontroller as bidirectional

any help would be appreciated..
Last edited:

One possible option is the use of a Port Expander or Shift Register.

6 Digits 7-Segment LED Multiplexing using a Shift Register

The port pins of a PIC can only be configured as input or output, not bidirectional, however the direction of a port pin can be changed during runtime via software.

Typically hardware peripheral modules like the USART, SPI, I2C, etc require the port pins used by the hardware peripheral module be initially configured to a known state/direction, the peripheral module then changes the direction of the pin as required during operation.

The same is true of software implement peripherals or soft peripherals, the ports pins are initially configured to a required state/direction and it is the task of the software routine to change the direction of the port pin as required during execution.

  • Like
Reactions: asking


    Points: 2
    Helpful Answer Positive Rating
Great information :) thanks :)

Not open for further replies.

Part and Inventory Search

Welcome to