Initialisierung: ------------------------------------------ void init_eeprom(void) { SPI_CS_EEPROM=0; SPI_WRITE(0b00000110); // Write Enable SPI_CS_EEPROM=1; delay_ms(40); SPI_CS_EEPROM=0; SPI_WRITE(0b00000001); SPI_WRITE(0b00000010); // Write Status Register SPI_CS_EEPROM=1; delay_ms(2); } write- und read-funktionen: ----------------------------------------------- void eeprom_write(int16 adresse,int8 wert) { int8 byte1,byte2; byte2=adresse; adresse>>=8; byte1=adresse; SPI_CS_EEPROM=0; SPI_WRITE(0x02); SPI_WRITE(byte1); SPI_WRITE(byte2); SPI_WRITE(wert); SPI_CS_EEPROM=1; } int8 eeprom_read(int16 adresse) { int8 wert,byte1,byte2; byte2=adresse; adresse>>=8; byte1=adresse; SPI_CS_EEPROM=0; SPI_WRITE(0x03); SPI_WRITE(byte1); SPI_WRITE(byte2); wert=SPI_READ(); SPI_CS_EEPROM=1; return wert; } Test-funktion: -------------------------------------- int8 wert=0,wert_out,byte1,byte2; int16 adresse; adresse=0x4369; wert_out=0x55; byte2=adresse; adresse>>=8; byte1=adresse; lcd_curs(cursor_off); lcd_putc("\fEEPROM-Test:"); // \f=desplay löschen! lcd_gotoxy(0,1); printf(lcd_putc,"Adresse: %2X%2X",byte1,byte2); eeprom_write(adresse,wert_out); wert=eeprom_read(adresse); lcd_gotoxy(0,2); printf(lcd_putc,"Wert: %2X",wert);