Re: Serial Eeprom
Hi,
here is the code in C on how to Read and Write to the internal eeprom of the PIC:
*****************************************************
void my_eeprom_write (char addr, char value)
{
while(WR)
continue;
EEADR=(addr);
EEDATA=(value);
EECON1&=0x7F;
CARRY=0;
if(GIE)
CARRY=1;
GIE=0;
WREN=1;
EECON2=0x55;
EECON2=0xAA;
WR=1;
asm("nop");
asm("nop");
if(CARRY)
GIE=1;
WREN=0;
}
**************************************************
/*********************************************************************
* EEPROM_READ_Function *
*********************************************************************/
unsigned char my_eeprom_read (char addr)
{
while(WR)
continue;
EEADR=addr;
EECON1&=0x7F;
RD=1;
//EEDATA;
return(EEDATA);
}
***************************************************************
For external use the I2C.