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.

PIC18 I2C (high / low) question

Status
Not open for further replies.

eepty

Full Member level 2
Joined
Oct 21, 2005
Messages
143
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,611
The PIC18F45K22 datasheet said for I2C function, the SCL.TRIS and SDA.TRIS should be set to high, and the hardware will change the output of SDA and SCL automatically.

However, in many I2C example code, it seems that they always set SDA.TRIS to 1 for output high at SDA pin, and set SDA to 0 for a output low.

Is this correct? Can I just set SDA pin (or SCL pin) to 1 for a output high and SDA pin (or SCL pin) to 0 for a output low?
 

the I2C SDA and SCLK lines have pull up resistors to pull then high, see the presentation
https://ww1.microchip.com/downloads/en/devicedoc/i2c.pdf

one sets the TRIS bits to 1 to make the digital pins tri-state (hence pulled high) then when the I2C is enabled it takes control of the pins pulling the data and clock signals low as required
 
  • Like
Reactions: eepty

    eepty

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top