View Full Version : I2C trouble : SDA won't go up... and it's not a hardware issue

02-19-2007, 05:22 AM
Hi guys,

I'm writing some assembly code to access the 24LC256 connected to my Prop' . I have a fairly basic setup on a breadboard, with EEPROM and a 10 K pull-up to 3.3V on SDA. The thing works (i.e. I can program the EEPROM from the PC and the chip will boot from it. I can observe correct I2C transactions on the oscilloscope)

I've written I2C code before (for Atmel AVR's) and I'm confortable with the Prop's assembly language (I actually don't use Spin except for launching assembly code) so I wrote the usual routines to read and write bits, bytes, and to generate start and stop conditions. Nothing complicated there.

Yet I face a problem that defies logic. My I2C code starts like this :

org 0
mov DIRA,SCL 'SCL : mask determining the SCL pin
mov OUTA,SCL 'SCL default state, high

Since the cog has just been started, initially all pins are inputs (their DIRA bit is cleared), and since the pin for SDA has a pull-up on it, I should see 3.3V on that pin, but instead I see zero volt.

Since the EEPROM works when the Prop' boots from it, it can't be a hardware problem.

I've tried pretty much everything on the software side, including clocking SCL to see if I could reinitialize the EEPROM, to no avail : SDA remains low.

Do you have any idea what's causing this ?

I should add that there are other programs running on other cogs on the same chip, but none uses the pins connected to the EEPROM (I've triple-checked, since this was the only thing I could see that could cause a problem. Also, I've tried sending bytes to verify the timing of my routines, and it's really by the book, but I never get an ACK from the EEPROM)


Mike Green
02-19-2007, 05:33 AM
You'd have to post much more of your code. I would suggest downloading a copy of the Propeller OS and looking at the OS_loaderInit object which includes an assembly I2C routine that works with the boot EEPROM as well as other EEPROMs connected to the same or other pins.


02-19-2007, 06:24 PM

try it in SPIN to prove hardware vs code issue.

something like:
dira[SCL_pin] ~~
outa[SCL_pin] ~~