Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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?
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
the I2C SDA and SCLK lines have pull up resistors to pull then high, see the presentation
http://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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top