Quote:
|
Originally Posted by IrisLab
Couple of questions...
1. Can you explain addrH, addrL, and data a little more? For readEE, are these the locations of the high and low byte in the EEPROM where you want to write? What are typical values for these addresses, if so? For writeEE same thing?
|
Here is a slightly improved version of the read/write function. I've combined addrH and addrL into address. Valid values for address should be 0-1024 (since the size of the EEPROM is 1KB). (IFI originally said that it was only 256 but they have since corrected their mistake)
data can be any char value (0:255 for unsigned; -128:127 for signed)
This is applicable to both readEE() and writeEE()
Code:
char readEE(unsigned short address) {
// Load address into address register
EEADRH = ((address>>8)&0x03); //Bits 2-7 are masked off since EEPROM is only 1KB
EEADR =(address&0xFF);
//Configuration as per manual
EECON1bits.EEPGD =0;
EECON1bits.CFGS =0;
EECON1bits.RD =1;
return EEDATA;
}
void writeEE(unsigned short address, char data)
{
EEADRH = ((address>>8)&0x03);
EEADR =(address&0xFF);
EEDATA = data;
//Configuration as per manual
EECON1bits.EEPGD =0;
EECON1bits.CFGS =0;
EECON1bits.WREN =1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
}
Quote:
|
Originally Posted by IrisLab
2. I read in another thread that you (or someone) is developing a copyCat (?) where you'd record user input into the EEPROM. How big (bytes) is the EEPROM? Do you have sample code for the CopyCat?
|
EEPROM size is 1024 bytes (1KB)
I am not the person working on the CopyCat program. Post in this
thread for any questions on CopyCat.
Quote:
|
Originally Posted by IrisLab
I'm new to the forum...so I hope I'm asking the right questions in the right place.
Thanks!
|
Welcome! And, yes you are in the right location.