i'm trying to write to the internal EEPROM of
the 16c84. the problem is that i can read from it ( pre-programmed values) but i
can't write to it. i'm using te following (standard)program to read and write
the 16c84. can someone tell me what i'm doing wrong ????
#include <16C84.h>
#define
Enable_EE_WR EECON1.WREN = 1
#define
Disable_EE_WR EECON1.WREN = 0
#define
EEProm_Rd
EECON1.RD = 1
#define EEProm_Writing
EECON1.WR
int Read_EEProm(registerw addr);
void
Write_EEProm(registerx addr, registerw data);
void main()
{
unsigned int addr,
data;
data = 0x18; // Data to be
written/read
addr = 0x00; // Address to write
to
//-------------- EEPROM WRITE
----------------
Write_EEProm(addr,data);
while(EEProm_Writing);
//--------------- EEPROM READ
-----------------
data = Read_EEProm(addr);
TRISB = 0x00;
PORTB =
data;
while(1);
}
int Read_EEProm(registerw addr)
{
EEADR = addr;
EEProm_Rd;
return(EEDATA);
}
void Write_EEProm(registerx addr, registerw
data)
{
Enable_EE_WR;
EEDATA = data;
EEADR =
addr;
#asm
MOVLW 0x55
MOVWF EECON2
MOVLW 0xAA
MOVWF
EECON2
BSF
EECON2,WR
#endasm
}