pic - PIC16F877 + 24LC64 via i2c -


my task copy first 255 bytes external eeprom (24lc64) internal (pic16f877) via i2c bus. i've read an1488, datasheets, mikroc gide (oh, yes, i'm using mikroc), hopeless.. meaning code trys read smtng then, reading pic's eeprom @ programmer (which can't read 24lc64, don't know what's on it, there smtng defenately , different i'm getting), , i'm getting eeprom filled "a2" or "a3". guess it's first addr, i'm addressing 24lc64. pls inspect code (it's quite small =)) , point me @ misstakes.

char i; unsigned short data;  void main(){    portb = 0;    trisb = 0;    i2c1_init(100000);    portb = 0b00000010;     (i = 0x00; i<0xff; i++) {       i2c1_start();       i2c1_wr(0xa2); //being 1010 001 0       //i'm getting full internal ee filled what's in brackets above       i2c1_wr(0b00000000);       i2c1_wr(i);       i2c1_repeated_start();       i2c1_wr(0xa3); //being 1010 001 1       data = i2c1_rd(0);       i2c1_stop();        eeprom_write(i, data);  //how 1010 001 0 here???        delay_100ms();    }     portb = 0b00000000;     while (1) {     } }  

p.s. i've tryed sequantial read, "reads" (again "a2"..) 1st byte.. i've posted one..

p.s.s. i`m working in "hardware", no proteus involved..

p.s.s.s. can't test writing, because have 1 24lc64 important info on it, it's pulld vcc on it's wp pin...

this isn't specific answer more of checklist i2c comms, since it's difficult problem without looking @ scope , without delving api calls you've provided.

  1. check address of eeprom. i2c uses 7-bit address r/w bit appended end, it's easy make mistake here.
  2. check command sequence eeprom expects receive "data read"
  3. check how i2c_ api you're using deals acks eeprom. need handled somewhere (usually in isr) , it's not obvious they're dealt example.
  4. check you've got correct pull-ups on sda , scl per requirements of design - they're needed i2c work.

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -