• 0

eeprom programming help required for a PIC12F1840


Question

Hi I'm need to write 1 byte of data to eeprom memory and struggling to find a working example,  I read the data sheet but it leave more questions then it answers.   Googled without too much luck. So may I tell you what I've think and maybe you would be kind enough to put me straight.
 
I code below is the extract of my full code but its not working.
 
Questions,
1) the Address, does this start a 0 or should it be a physical address?  can't seem to find anything explaining this and whats is the physical address
2) I've see interrupts should be disabled, but others are say its not required? I'm thinking its dependant on how complex the interrupts are and times, but can not find a good explanation.
3) have I missed anything from the code below
 
Many thanks Geoff
 
/* Prototypes */
unsigned char eeprom_read(unsigned char address);
void eeprom_write(unsigned char addreess, unsigned char value);   
   
/* Init the eeprom data area, only on byte is really needed  */   
__EEPROM_DATA(0xff,0,0,0,0,0,0,0);
/* Define the variables   */ 
volatile unsigned char EE_Value            = 0xbb;
            unsigned char EE_Address        = 0x00;

/* Writing the flag to eeprom  */
    if (G12_Button_Changed                  == 1
    &&  EE_Value                                != IH01_Button_Pressed)  /* IH01 is 1 or 0 */
        {   
        EE_Value                                   = IH01_Button_Pressed;
        EECON1bits.WREN                      = 1;
        eeprom_write(EE_Address, EE_Value);
        EECON1bits.WREN                      = 0;
    }
    
   
 
#1
 
Link to post
Share on other sites

1 answer to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now