please dont rip this site

PIC Microcontoller Memory Method

3663/3927

Internal EEPROM access on 16F87x devices

Sam Linder [SamL at IN-INC.COM] says:

The following routines work for the 16F874/16F877 - not sure about the 16F871.
// **************************************************
// Function Name: Read8BitDataFromEEprom
//
// Description: Read characterization data out of on-board EEPROM
//
// Inputs:
//    eeaddress: 8-bit EEPROM address to read
//
// Outputs:
//    8-bit data stored at EEPROM address
//
unsigned char
Read8BitDataFromEEprom(unsigned char eeaddress)
{
    eeaddress &= 0x7F;

    eeadr = eeaddress;
    eepgd = 0;
    rd = 1;
    return(eedata);

} // end of Read8BitDataFromEEprom()


// **************************************************
// Function Name: Write8BitDataToEEprom
//
// Description: write 8-bit characterization data to on-board EEPROM
//
// Inputs:
//      data_address:  8-bit EEPROM address
//         datavalue:  8-bit data
//
// Outputs: none
//
void
Write8BitDataToEEprom(unsigned char data_address, unsigned char datavalue)
{

    data_address &= 0x7F;

    eeadr = data_address;   // establish address to write to
    eedata = datavalue;     // get data to write
    eepgd = 0;              // set for access to data memory
    wren = 1;               // set eeprom write enable bit
    //gie = 0;

#asm
retry:
    bcf INTCON,GIE          // disable interrupts for write sequence
    btfsc INTCON,GIE        // make sure bit cleared
    goto retry              // (int could have occurred 1/2way thru
instruction)
#endasm

    eecon2 = 0x55;          // required
    eecon2 = 0xAA;          //  write
    wr = 1;                 //   sequence
    gie = 1;                // ok to re-enable interrupts
    do {                    // wait for write to complete
        ; // nothing
    } while(wr);
    wren = 0;               // clear eeprom write enable bit
    eeif = 0;               // clear write complete interrupt flag

} // end of Write8BitDataToEEprom()


Questions:


file: /techref/microchip/16f87xeeprom.htm, 2KB, , updated: 2003/5/8 13:52, local time: 2008/7/5 06:12, owner: MRL-FAU-IAA,
TOP NEW HELP FIND: 
38.103.63.16:LOG IN
©2008 PLEASE DON'T RIP! DO: LINK / DIGG! / MAKE!

 ©2008 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it!
<A HREF="http://www.piclist.com/techref/microchip/16f87xeeprom.htm"> PIC Microcontoller Memory Method</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be reviewed) Just type in the box and press the Post button. (HTML welcomed!): A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Did you find what you needed?

  PICList 2008 contributors:
o List host: MIT, Site host massmind.org, Top posters @20080705 Apptech, Jinx, Xiaofan Chen, Alan B. Pearce, David VanHorn, Bob Axtell, William \Chops\ Westfield, Cedric Chang, olin piclist, Gerhard Fiedler,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Shultz Electronics, Larry Williams, David VanHorn, Bryan Whitehouse, Timothy Weber, David Challis. Peter Todd. on-going support is MOST appreciated!
* Contributors: Neil Narwani, David Cary, Elemer AM Nyiry, Philip J Taylor, Gus Calabrese of Omegadogs.com, Gautama Venegas, Patrick B. Murphy, William Chops Westfield, Peter Todd, Leslie Ellis
  'What can I do?' - SiCKO

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .