Writing to EEPROM..."

Thread Starter

ATM

Joined Oct 8, 2009
31
Hello, I'm experimenting with the EEPROM of a PIC16F88. At the minute I'm trying to write an arbitary value to an address in the EEPROM. However I'm seeing the " error: left operand must be l-value" error message. I have a vague idea that this is something to do with trying to assign a variable to a constant(first two lines in my eeprom_write function) but i'm stumped on as how to get around it. The code I have written using sourceboost is:

Rich (BB code):
void eeprom_write()
{

EEADR=01111011b;                                       //write address to EEADR
EEDATA=01110001b;                         //write 8-bit data value to EEDATA
eecon1.7=0;                                                    //access data memory
eecon1.2=1;                                                    //allow write cycles      
intcon.7=0;                                           //temporarily disable interrupts
eecon2=01010101b;                                        //write 55h to eecon2
eecon2=10101010b;                                          //write AAh to eecon2
eecon1.1=1;                                                    //Initiates a write cycle
intcon.7=1;                                                    //re-enable interrupts
eecon1.2=0;                                               //Inhibits EEPROM writes                                                    
while(pir2.4==0)
    {
        nop();                                             //wait for write to complete
    }
pir2.4=0;
Currently I just want to write values to the EEPROM, simulate the progam and check for correct operation. Any help is appreciated, thanks.
 

AlexR

Joined Jan 16, 2008
732
In SourceboostC/C++ register names written in capital letters refer to the address of the register and register names in lower case refer to the contents of the register so what your statement EEADR=01111011b; translates to after the pre-processor has done its substitutions is 0x10D=01111011b; which is clearly nonsense. As others have said using lower case should solve your problem.
 
Top