Monday 19 October 2015

PIC12F675 EEPROM




#include<pic.h>
#include<htc.h>
#define __PIC12F675_H                    //header file for ic
__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_ON & MCLRE_OFF & BOREN_ON & CP_OFF & CPD_OFF);  //config word
#define LED GP0                         //define pin 0
#define _XLAT_FREQ 4000000             //define cpu frequency

void delay(unsigned int i)
{
while(i--);
}


void main()
{
ANSEL=0X00;                  //SET PORT AS DIGITAL I/O
ADCON0=0X00;                 //SHUT OFF THE A/D CONVERTER
CMCON=0X00;                  //SHUT OFF THE COMPRATOR
VRCON=0X00;                  //SHUT OFF THE VOLTAGE REFERENCE
TRISIO=0X00;                 //GP3 INPUT,REST ALL OUTPUT
GPIO=0X00;                   //MAKE ALL PIN 0

eeprom_write(0, 0xFF); // Write 0xFF at 0 address location

if( eeprom_read(0) == 0xFF ) // Read from 0 address location
LED = 1; // If eeprom was written correctly
else
LED = 0; // If eeprom was not written correctly

while(1)
{
}

}

No comments:

Post a Comment