PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 06, 2006 1:39 pm |
|
|
| Quote: | | compiler version: PCM 3.225. |
Here are two substitute functions, which copy the CCS functions
for PCM vs. 3.249. These functions should fix the problems with
data eeprom in your compiler version. Use these functions instead
of the built-in functions.
| Code: | #include <16F690.h>
#fuses XT, NOWDT, NOPROTECT, PUT, BROWNOUT
#use delay(clock=4000000)
// Registers and bits used for Data eeprom R/W:
#byte INTCON = 0x0B
#byte EEDAT = 0x10C
#byte EEADR = 0x10D
#byte EEDATH = 0x10E
#byte EEADRH = 0x10F
#byte EECON1 = 0x18C
#byte EECON2 = 0x18D
#bit GIE = INTCON.7
#bit RD = EECON1.0
#bit WR = EECON1.1
#bit WREN = EECON1.2
#bit WRERR = EECON1.3
#bit EEPGD = EECON1.7
//------------------------------------------
void my_write_eeprom(int8 addr, int8 data)
{
int8 save_intcon;
EEADR = addr;
EEDAT = data;
EEPGD = 0;
WREN = 1;
save_intcon = INTCON;
GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
WR = 1;
while(WR);
WREN = 0;
INTCON |= save_intcon;
}
//--------------------------------------
int8 my_read_eeprom(int8 addr)
{
int8 retval;
EEADR = addr;
EEPGD = 0;
RD = 1;
retval = EEDAT;
return(retval);
}
//===================================
void main()
{
int8 c;
my_write_eeprom(0, 0x55);
c = my_read_eeprom(0);
while(1);
} |
|
|