Yesterday i found what was going wrong... It was the %1010000! I dont know why this is not working. I wrote $A0 = %1010000 in Hexadecimal and now it is ok! Thanks all the people for their messages!! > With A0,A1 and A2 not used for the I2C device address these 3-bits > select which of the eight 256 word blocks of memory are accessed. > In this case, for this device, you would use these 3-bits for block > selection and you can leave A0,A1 and A2 NC. > > Try moving DPIN & CPIN over to portb and see what you get. > > Sorry I don't have an F84A to wire-up & test, but this example below > does work with a 24LC16B wired to an F877 on a PICDEM 2 Plus > board. Just tested it. Works fine. > > WP = gnd > DPIN & CPIN both pulled-up to Vcc through 4.7K resistors > > DEFINE OSC 20 > > DPIN var PORTB.1 ' I2C data pin > CPIN var PORTB.2 ' I2C clock pin > B0 var byte > B1 var byte > > Loop: > For B0 = 0 To 15 > I2CWRITE DPIN,CPIN,$A0,B0,[B0] ' Write address to itself > Pause 10 ' Delay after write > Next B0 > > For B0 = 0 To 15 > I2CREAD DPIN,CPIN,$A0,B0,[B1] ' Read > HSerout [DEC B1,13,10] ' Print > Next B0 > PAUSE 250 > Goto loop > > This definitely works. > Regards, > > -Bruce > tech@rentron.com > http://www.rentron.com > > > > > Include "modedefs.bas" ' Include serial modes > > DEFINE OSC 4 > > DEFINE I2C_SCLOUT ' make clock pin bipolar > > DPIN var PORTA.3 ' I2C data pin > > CPIN var PORTA.0 ' I2C clock pin > > B0 var byte > > B1 var byte > > B2 var byte > > > > For B0 = 0 To 15 ' Loop 16 times > > I2CWRITE DPIN,CPIN,%1010000,B0,[B0] ' Write each location's address to itself > > Pause 10 ' Delay 10ms after each write > > Next B0 > > > > loop: For B0 = 0 To 15 step 2 ' Loop 8 times > > I2CREAD DPIN,CPIN,%1010000,$1,[B1,B2] ' Read 2 locations in a row > > Serout PORTA.2,N9600,[#B1," ",#B2," "] ' Print 2 locations > > Next B0 > > > > Serout PORTA.2,N9600,[10] ' Print linefeed > > > > Goto loop > > > > > > I am using a 4MHZ crystal. The 24LC16B connections are: > > Vdd to +5 > > Vss to GND > > A0-A2 to GND > > WP to GND > > SCL to a pull-up resistor 4.7K (it goes to VDD) and to PORTA.0 of pic > > CDA to a pull-up resistor 4.7K (it goes to VDD) and to PORTA.3 of pic > > > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > ____________________________________________________________________ http://www.freemail.gr - dyqe\m upgqes_a gkejtqomijo} tawudqole_ou. http://www.freemail.gr - free email service for the Greek-speaking. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu