English
Language : 

W78IRD2 Datasheet, PDF (70/76 Pages) Winbond – 8-BIT MICROCONTROLLER
W78IRD2
22. APPLICATION NOTE
22.1 In-System Programming (ISP) Software Examples
This application note illustrates the in-system programmability of the Winbond W78IRD2 Flash
EPROM microcontroller. In this example, the microcontroller boots from 64 KB AP Flash EPROM bank
and waits for a key to enter ISP mode to re-program the 64-KB AP Flash EPROM. While in ISP mode,
the microcontroller executes the loader program in the 4-KB LD Flash EPROM. The loader program
erases the 64-KB AP Flash EPROM and then reads the new code from an external SRAM buffer (or
through other interfaces) to update the 64-KB 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 = 40 MHz
;*******************************************************************************************************************
.chip 8052
.RAMCHK OFF
.symbols
CHPCON
CHPENR
SFRAL
SFRAH
SFRFD
SFRCN
EQU
EQU
EQU
EQU
EQU
EQU
BFH
F6H
C4H
C5H
C6H
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
MOV CHPENR, #59H
MOV CHPCON, #03H
MOV TCON, #00H
MOV IP, #00H
MOV IE, #82H
; CHPENR = 87H, CHPCON REGISTER WRTE ENABLE
; CHPENR = 59H, CHPCON REGISTER WRITE ENABLE
; CHPCON = 03H, ENTER IN-SYSTEM PROGRAMMING MODE
; TR = 0 TIMER0 STOP
; IP = 00H
; TIMER0 INTERRUPT ENABLE FOR WAKE-UP FROM IDLE MODE
- 70 -