On Jul 3, 2008, at 1:54 AM, dave jones wrote: > I want to read/set RTC date and time with 8051 via the i2c protocol. > I2C implementation protocol I used is > http://sdccokr.dl9sec.de/dld/top03_pac01.zip
Yes, this is a "bit bang" implementation of the I2C protocol. > Also, I found out there are no ouput voltage with the SDA pin, I > should set SDA = 0. > I guess that i2c implementation I got is wrong? Thanks. What actual chip are you using, what part number from what manufacturer? I'm assuming it's not an actual Intel 8051. The bit-bang code you referenced above is written to use two Port 3 pins as I2C's SDA and SCL signals. Since the I2C protocol depends upon other chips pulling down the SDA line occasionally (ACK bit, etc), you need to make sure you're using I/O pins that'll work for I2C use. They need to be open-drain outputs, not full-totem-pole outputs. For open-drain lines, you'll need external pullup resistors, typically 4.7K or 10K ohm. Standard mcs51 implementations have on-chip pullup resistors on all Port 3 pins. Full totem-pole output drivers, which can either pull a pin to a hard 1 or 0 because they have a FET for each state, just plain won't work for I2C. The standard 8051's output drivers have a FET that can pull a line down to a 0, and on-chip pullup resistors to create a 1. The exception to this is the pins of Port 0, are open-drain outputs with no on-chip pullup resistors, so they can't pull the line up to a 1 by themselves. (when in normal I/O mode, that is...they have pullup FETs which become active when Port 0 is used for external memory access) So anyway, double check the I/O port pin types that you're using. Do you have access to an oscilloscope? -Dave -- Dave McGuire Port Charlotte, FL ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user