| Philips Semiconductors | 
 | 
 | 
 | 
 | User’s Manual - Preliminary - | ||
| 
 | 
 | 
 | |||||
| FLASH PROGRAM MEMORY | P89LPC906/907/908 | ||||||
| r | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
| ;* | Inputs: | data | to write(byte) | 
 | * | 
 | |
| ;* | R5 = | 
 | * | 
 | |||
| ;* | R7 = element address(byte) | 
 | * | 
 | |||
| ;* | Outputs: | 
 | 
 | 
 | * | 
 | |
| ;* | None | 
 | 
 | 
 | 
 | * | 
 | 
| CONF EQU | 6CH | 
 | 
 | 
 | 
 | 
 | |
| WR_ELEM: | FMADRL,R7 | ;write the address | |||||
| 
 | MOV | ||||||
| 
 | 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: | C | 
 | ;set error flag if bad | ||||
| 
 | SETB | 
 | |||||
| 
 | RET | 
 | 
 | ;and return | 
 | 
 | |
| 
 | 
 | 
 | |||||
| 
 | 
 | Figure  | |||||
| 
 | 
 | 
 | 
 | ||||
| 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); | 
 | 
 | 
 | 
 | ||
| 
 | } | 
 | 
 | 
 | 
 | 
 | 
 | 
| 
 | 
 | 
 | |||||
| 
 | 
 | Figure  | |||||
| 2003 Dec 8 | 94 | 
