PDA

View Full Version : 24c256 by atmel



tom
- 11th August 2006, 14:34
Hello pic friends!
One simple question. Is it possible somehow to read and write
24C256 eeprom from Atmel with i2cread and i2cwrite commands?
the protocol is 2 wire, not i2C but it looks similar?

mister_e
- 11th August 2006, 15:51
Yes it is possible. 2 wires or I2C is often the same thing. Same for SPI, 3 wire interface and Microwire.

tom
- 12th August 2006, 12:50
Why then this piece of code doesn't work on Atmel 24C256 and works with
24LC32A from Microchip? I get five times 04 on LCD in case of Atmel chip.
The hardware configuration is the same: pin1,2,3,8 on Vcc,4 on gnd, 5 SDA amd 6 scl with 4K7 pull ups. Pic is 16F876 with 20MHz crystal.


define LOADER_USED 1
define OSC 20
define LCD_EREG PORTC
define LCD_EBIT 1

Symbol SDA = PORTC.2
Symbol SCL = PORTC.3
addr_EE var word
value var byte
CTRL_EE con %10101110

ADCON1=7
TRISA=$00

lcdout $fe,1
main:


lcdout "Writing..."
pause 200

value=1
addr_EE=0
I2CWrite sda, scl, CTRL_EE, addr_EE, [value]
pause 10

value=2
addr_EE=1
I2CWrite sda, scl, CTRL_EE, addr_EE, [value]
pause 10

value=3
addr_EE=2
I2CWrite sda, scl, CTRL_EE, addr_EE, [value]
pause 10

value=4
addr_EE=3
I2CWrite sda, scl, CTRL_EE, addr_EE, [value]
pause 10

value=5
addr_EE=4
I2CWrite sda, scl, CTRL_EE, addr_EE, [value]
pause 10

lcdout $fe,1,"Finished"

lcdout $fe,1
for addr_EE=0 to 4
I2CRead sda, scl, CTRL_EE, addr_EE, [value]
lcdout dec2 value," "
next
pa: goto pa
end

Thanks for answers!

mister_e
- 12th August 2006, 19:03
There's no A2 assignement for this one...how about if you change...


CTRL_EE con %10101110


to


CTRL_EE con %10100110


be sure you also set WP (pin 7) to GND.

tom
- 13th August 2006, 11:20
Thank you very mach Mister E!
It works now! i was in a hurry and didn't look at datasheet with enough
attention.
Thanks again.