Gast
#145038
Ich versuche mit codevision auf die 24Cxx (xx= 512 oder 256) zu zugreifen aber ohne Erfolg. Ich werde für jede Hilfe dankbar. Wie gehe ich vor: 24Cxx (xx= 512 oder 256)<--- -> uC(AT90S8515) SCL(Pin 6) -------------------> PORTB.4 SDA(Pin 5) -------------------> PORTB.5 PINs A0, A1 --> GND WP -----------> GND -------------------- Program: #include <90s8515.h> // Standard Input/Output functions #include <stdio.h> #include <delay.h> // I2C Bus functions #asm .equ __i2c_port=0x18 ;PORTB .equ __scl_bit=4 .equ __sda_bit=5 #endasm #include <i2c.h> /* read a byte from the EEPROM */ unsigned char eeprom_read(unsigned int address) { unsigned char data; i2c_start(); i2c_write(EEPROM_BUS_ADDRESS); i2c_write(0x00FF & (address>>8));//(0x1F & (addr>>8)) i2c_write(0x00FF & address);//(0xFF & addr); i2c_start(); i2c_write(EEPROM_BUS_ADDRESS | 1); data=i2c_read(0); i2c_stop(); return data; } /* write a byte to the EEPROM */ void eeprom_write(unsigned int address, unsigned char data) { i2c_start(); i2c_write(EEPROM_BUS_ADDRESS); i2c_write(0x00FF & (address>>8)); i2c_write(0x00FF & address); i2c_write(data); i2c_stop(); delay_ms(5); } void main(void) { // Declare your local variables here unsigned char device; unsigned char i, eepVar; int temp = 0; PORTA=0x07; DDRA=0x07; // UART initialization UCR=0x18; UBRR=0x19; // I2C Bus initialization i2c_init(); eeprom_write(0x00aa,0x55); //0x55 eepVar = eeprom_read(0x00aa); if(eepVar){ printf("EEprom: %-X", eepVar); putchar(eepVar); printf("\n\t"); } else printf("\n\tEEPROM ERROR !"); // } while (1){ eeprom_write(0x0011,0x0A); //0x55 printf("EEPROM: %-X\n", eeprom_read(0x0011)); } } Was ist hier falsch mit den write und read programme? Danke