
W78LE516/W78L516A
- 32 -
11. APPLICATION NOTE: IN-SYSTEM PROGRAMMING SOFTWARE EXAMPLES
This application note illustrates the in-system programmability of the Winbond W78L516 Flash
EPROM microcontroller. In this example, microcontroller will boot from 64 KB AP FLASH EPROM
bank and waiting for a key to enter in-system programming mode for re-programming the contents of
64 KB AP FLASH EPROM. While entering in-system programming mode, microcontroller executes
the loader program in 4KB LD FLASH EPROM bank. The loader program erases the 64 KB AP
FLASH EPROM then reads the new code data from external SRAM buffer (or through other
interfaces) to update the 64KB AP FLASH EPROM.
EXAMPLE 1:
;*******************************************************************************************************************
;* Example of 64K AP FLASH EPROM program: Program will scan the P1.0. if P1.0 = 0, enters in-
system
;* programming mode for updating the content of AP FLASH EPROM code else executes the current
ROM code.
;* XTAL = 16 MHz
;*******************************************************************************************************************
.chip 8052
.RAMCHK OFF
.symbols
CHPCON EQU BFH
CHPENR EQU F6H
SFRAL EQU C4H
SFRAH EQU C5H
SFRFD EQU C6H
SFRCN EQU C7H
ORG 0H
LJMP 100H ; JUMP TO MAIN PROGRAM
;************************************************************************
;* TIMER0 SERVICE VECTOR ORG = 000BH
;************************************************************************
ORG 00BH
CLR TR0 ; TR0 = 0, STOP TIMER0
MOV TL0, R6
MOV TH0, R7
RETI
;************************************************************************
;* 64K AP FLASH EPROM MAIN PROGRAM
;************************************************************************
ORG 100H
MAIN_64K:
MOV A, P1 ; SCAN P1.0
ANL A, #01H
CJNE A, #01H, PROGRAM_64K ; IF P1.0 = 0, ENTER IN-SYSTEM PROGRAMMING MODE
JMP NORMAL_MODE
PROGRAM_64K:
MOV CHPENR, #87H ; CHPENR = 87H, CHPCON REGISTER WRTE ENABLE
MOV CHPENR, #59H ; CHPENR = 59H, CHPCON REGISTER WRITE ENABLE
MOV CHPCON, #03H ; CHPCON = 03H, ENTER IN-SYSTEM PROGRAMMING MODE