hi!
i've got a 24aa64 i2c-eeprom from microchip and wanted to programm it using the following code (ccs-c-compiler, PIC18F458):
does anybody know, why it doesn't work or is there any sample file for writing/reading from/to serial eeprom? the ex_extee.c is not really a help...
thank you!
cya
i2c2k
[/code]
i've got a 24aa64 i2c-eeprom from microchip and wanted to programm it using the following code (ccs-c-compiler, PIC18F458):
Code:
#use i2c(master, scl=PIN_C3, sda=PIN_C4, slow, force_hw)
......
//write
i2c_start();
i2c_write(0b10100000); //control byte
i2c_write(0b00000000); //adr hi
i2c_write(0b00000000); //adr lo
i2c_write('h'); //data 0
i2c_write('e'); //data 1
i2c_write('l'); //data 2
i2c_write('l'); //data 3
i2c_write('o'); //data 4
i2c_stop();
//read
i2c_start();
i2c_write(0b10100000); //control byte (set address)
i2c_write(0b00000000); //adr hi
i2c_write(0b00000000); //adr lo
i2c_start();
i2c_write(0b10100001); //control byte (read data)
printf("Data from EEPROM: %c", i2c_read());
printf("%c", i2c_read());
printf("%c", i2c_read());
printf("%c", i2c_read());
printf("%c\n", i2c_read());
i2c_stop();
does anybody know, why it doesn't work or is there any sample file for writing/reading from/to serial eeprom? the ex_extee.c is not really a help...
thank you!
cya
i2c2k
[/code]