eeprom.c

C2C-plus code that uses a 16F84 to read a thermocouple via a Maxim's Max6674. (by Ryan Dumouchel).



//EEPROM by Petr Mervart.


#include "eeprom.h"

void EEPROM_WRITE(char adresa,char data)  //write to EEPROM
{
   EEADR=adresa;
   EEDATA=data;

   set_bit(EECON1,WREN);
   EECON2=0x55;
   EECON2=0xAA;
   set_bit( EECON1, WR );       // start writing
   while(EECON1&2);          // cycle until WR reg. EECON1 = 1 (writing..)
   clear_bit( EECON1, WREN );

}

char EEPROM_READ(char adresa)     // read from EEPROM
{
   EEADR = adresa;
    set_bit( EECON1, RD);      // start reading
    return EEDATA;
}
void EEPROM_NULL()             // erase all EEPROM
{
    EEADR=0;
    while(EEADR<=63)
    {
      EEDATA=0;
      EEPROM_WRITE(EEADR,EEDATA);
   }
}



http://www.sourceboost.com/home.html

Copyright © 2002-2006 SourceBoost Technologies