PDA

View Full Version : I2C to AT24C512 eeprom not working



yourmomOS
- 25th March 2006, 19:22
Hi, newb here, got a question about I2C and two-wire interface. I have been told that if a datasheet just says two-wire serial without a protocol, then it is probably I2C but they dont put it on there because of licensing issues. Is this true or not? Also, I have an AT24C512 that I can not seem to get data from. Here is the DATA SHEET: http://www.atmel.com/dyn/resources/prod_documents/doc1116.pdf#search='at24c512'

I have left A0 and A1 floating. I have data and clock pulled high with 2.2k resistors. I have also tried 4.7 k as well. Here is my code:

define OSC 20
CMCON = 7
Cont con %10100000
x var byte
x = 8
serout2 PORTB.2, 84, [x]
MAIN:
high PORTB.0
pause 1000
i2cwrite PORTB.7, PORTB.6, cont, 1, [9]
pause 1000
i2cread PORTB.7, PORTB.6, cont, 1, [x]
pause 1000
serout2 PORTB.2, 84, [x]
serout2 PORTB.2, 84, ["DONE"]
low PORTB.0
pause 1000
GOTO main

When I run the program I keep getting ascii character 128 interspersed with "DONE". I have tried changing Cont to $A0 with no luck. I have tried large pauses between reading and writing also. Can anyone tell me what I am doing wrong? Thanks in advance. PS...Pic is a 16f628.