if (cnt7f >= 16)
{
IspProgram(); // Invoke the download module (****important statement ****)
}
}
else
{
cnt7f = 0;
}
RI = 0; // Clear the reception completion flag
}
}
void main()
{
SCON = 0x50; // Define the serial port mode as 8-bit, variable baud rate, no parity
bit
AUXR = 0x40;
TH1 = BAUD >> 8;
TL1 = BAUD;
TR1 = 1;
ES = 1; //Enable UART interrupt
EA = 1; //Enable CPU interrupt
P1M0 = 0;
P1M1 = 0;
while (1)
{
P1++;
}
}
User codes (assembly code)
; Operating frequency for test is 11.0592MHz
UARTBAUD EQU 0FFE8H ;Define the serial port baud rate (65536-11059200/4/115200)
ISPPROGRAM EQU 0FA00H ; ISP download program entry address
AUXR DATA 08EH ; Additional Function Control Register
CNT7F DATA 60H ; Receive 7F counter
ORG 0000H
LJMP START ;System reset entry
ORG 0023H
LJMP UART_ISR ; UART interrupt entry
UART_ISR:
PUSH ACC
PUSH PSW
JNB TI,CHECKRI ; Detect transmission interruption
CLR TI ; clear flag
CHECKRI:
JNB RI,UARTISR_EXIT ; Detect receive interruption
CLR RI ; clear flag