Philips P89LPC903 Light Therapy Device User Manual


 
Philips Semiconductors
User’s Manual - Preliminary -
P89LPC901/902/903
FLASH PROGRAM MEMORY
2003 Dec 8 98
r
Figure 14-4: Assembly language routine to erase/program a flash element
Figure 14-5: C-language routine to erase/program a flash element
;* Inputs: *
;* R5 = data to write(byte) *
;* R7 = element address(byte) *
;* Outputs: *
;* None *
CONF EQU 6CH
WR_ELEM:
MOV FMADRL,R7 ;write the address
MOV FMCON,#CONF ;load CONF command
MOV FMDAT,R5 ;write the data
MOV R7,FMCON ;copy status for return
MOV A,R7 ;read status
ANL A,#0FH ;save only four lower bits
JNZ BAD ;see if good or bad
CLR C ;clear error flag if good
RET ;and return
BAD:
SETB C ;set error flag if bad
RET ;and return
unsigned char Fm_stat; // status result
bit PGM_EL (unsigned char, unsigned char);
bit prog_fail;
void main ()
{
prog_fail=PGM_EL(0x02,0x1C);
}
bit PGM_EL (unsigned char el_addr, unsigned char el_data)
{
#define CONF 0x6C // access flash elements
FMADRL = el_addr; //write element address to addr reg
FMCON = CONF; //load command, clears page reg
FMDATA = el_data; //write data and start the cycle
Fm_stat = FMCON; //read the result status
if ((Fm_stat & 0x0F)!=0) prog_fail=1; else prog_fail=0;
return(prog_fail);
}