Intel 8XC196MH Benutzerhandbuch

Seite von 579
16-33
PROGRAMMING THE NONVOLATILE MEMORY
The calling routine must pass two parameters to this routine — the data to be programmed (in
DATA_TEMP) and the address (in ADDR_TEMP). 
Figure 16-15.  Run-time Programming Code Example
PROGRAM:
PUSHA
;clear PSW, WSR, INT_MASK, INT_MASK1
LD
WSR,#7BH
;select 32-byte window with EPA0_CON
LD
COUNT,#5
;set up for 5 programming cycles
ANDB INT_PEND,#CLEAR_EPA0
;clear EPA0 pending bit
LDB
INT_MASK,#ENABLE_EPA0
;enable EPA0 interrupt
LDB
EPA0_CON,#EPA0_TIMER
;set up EPA0 as software timer
LOOP:
LD
TEMP0,TIMER1
;load TIMER1 value into TEMP0
ADD
EPA0_TIME,TEMP0,#PGM_PULSE
;load EPA0_TIME with TIMER1 + PGM_PULSE
EI
;enable unmasked interrupt(EPA0)
ST
DATA_TEMP,[ADDR_TEMP]
;store passed data at passed address
IDLPD #1
;enter idle mode
DJNZ COUNT,LOOP
;decrement COUNT and loop if not 0
;to complete 5 programming cycles
POPA
;restore PSW, WSR, and INT_MASKs
RET
EPA0_ISR:
RET