Philips P89LPC938 User Manual page 119

Single-chip microcontroller
Table of Contents

Advertisement

Philips Semiconductors
A C-language routine to load the page register and perform an erase/program operation is
shown below.
#include <REG938.H>
unsigned char idata dbytes[64]; // data buffer
unsigned char Fm_stat; // status result
bit PGM_USER (unsigned char, unsigned char);
bit prog_fail;
void main ()
{
}
bit PGM_USER (unsigned char page_hi, unsigned char page_lo)
User manual
PGM_USER:
MOV
FMCON,#LOAD
MOV
FMADRH,R4
MOV
FMADRL,R5
MOV
A,R7
MOV
R0,A
LOAD_PAGE:
MOV
FMDAT,@R0
INC
R0
DJNZ
R3,LOAD_PAGE ;do until count is zero
MOV
FMCON,#EP
MOV
R7,FMCON
MOV
A,R7
ANL
A,#0FH
JNZ
BAD
CLR
C
RET
BAD:
SETB
C
RET
prog_fail=PGM_USER(0x1F,0xC0);
{
#define LOAD 0x00 // clear page register, enable loading
#define EP 0x68 // erase & program page
unsigned char i; // loop count
FMCON = LOAD; //load command, clears page reg
FMADRH = page_hi; //
FMADRL = page_lo; //write my page address to addr regs
for (i=0;i<64;i=i+1)
{
FMDATA = dbytes[i];
}
Rev. 03 — 7 June 2005
;load command, clears page register
;get high address
;get low address
;
;get pointer into R0
;write data to page register
;point to next byte
;else erase & program the page
;copy status for return
;read status
;save only four lower bits
;
;clear error flag if good
;and return
;set error flag
;and return
UM10119
P89LPC938 User manual
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
119 of 139

Advertisement

Table of Contents
loading

Table of Contents