Writing to EEPROM..."

Discussion in 'Embedded Systems and Microcontrollers' started by ATM, Mar 1, 2010.

  1. ATM

    Thread Starter Member

    Oct 8, 2009
    31
    0
    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:

    Code ( (Unknown Language)):
    1.  
    2. void eeprom_write()
    3. {
    4.  
    5. EEADR=01111011b;                                       //write address to EEADR
    6. EEDATA=01110001b;                         //write 8-bit data value to EEDATA
    7. eecon1.7=0;                                                    //access data memory
    8. eecon1.2=1;                                                    //allow write cycles      
    9. intcon.7=0;                                           //temporarily disable interrupts
    10. eecon2=01010101b;                                        //write 55h to eecon2
    11. eecon2=10101010b;                                          //write AAh to eecon2
    12. eecon1.1=1;                                                    //Initiates a write cycle
    13. intcon.7=1;                                                    //re-enable interrupts
    14. eecon1.2=0;                                               //Inhibits EEPROM writes                                                    
    15. while(pir2.4==0)
    16.     {
    17.         nop();                                             //wait for write to complete
    18.     }
    19. pir2.4=0;    
    20.  
    Currently I just want to write values to the EEPROM, simulate the progam and check for correct operation. Any help is appreciated, thanks.
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Replace EEADR with eeadr and EEDATA with eedata and all will be fine.
     
  3. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    The capitals will get 'cha every time.
     
  4. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    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.
     
Loading...