RET
ISP_PROGRAMIAP:
MOV WDT_CONTR,#17H ;clear watchdog
MOV IAP_CMD,#2 ; programming command
MOV IAP_DATA,A ; send the current data to IAP data register
MOV IAP_TRIG,#5AH ; Trigger ISP command
MOV IAP_TRIG,#0A5H
NOP
NOP
NOP
NOP
MOV A,IAP_ADDRL ;IAP address +1
ADD A,#01H
MOV IAP_ADDRL,A
MOV A,IAP_ADDRH
ADDC A,#00H
MOV IAP_ADDRH,A
RET
ORG APENTRY
LJMP RESET
END
The ISP code includes the following external interface modules:
ISP_DOWNLOAD: program download entry address, absolute address FA00H
ISP_ENTRY: Power-on system self-check program (automatically called by the system)
For the user program, the user only needs to jump the PC value to ISPPROGRAM (ie FA00H, Absolute address), you
can update the code.
User codes (C language code)
// Operating frequency for test is 11.0592MHz
#include "reg51.h"
#define FOSC 11059200L // system clock frequency
#define BAUD (65536 - FOSC/4/115200) //Define the serial port baud rate
#define ISPPROGRAM 0xfa00 //ISP download program entry address
sfr AUXR = 0x8e; // Baud Rate Generator Control Register
sfr P1M0 = 0x92;
sfr P1M1 = 0x91;
void (*IspProgram)() = ISPPROGRAM; // define pointer function
char cnt7f; //Isp_Check Internally used variables
void uart() interrupt 4 // UART Interrupt Service Routine
{
if (TI) TI = 0; // send complete interrupt
if (RI) // Receive complete interrupt
{
if (SBUF == 0x7f)
{
cnt7f++;