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 14-4: Assembly language routine to erase/program a flash element

 

 

 

 

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 14-5: C-language routine to erase/program a flash element

2003 Dec 8

94

Page 94
Image 94
Philips P89LPC908, P89LPC906, P89LPC907 user manual Fmadrl