To illustrate
Add serial port initialization code and serial port interrupt code to the debugging program to realize uninterrupted power download program
TMOD|=0x20;
SCON=0x50;
TH1=0xfd; //12T clock 9600bps
TL1=0xfd;
TR1=1;
ES=1;
EA=1;
AUXR=AUXR|0x40; //Timer 1 uses 1T clock 9600*12=115200bps
void uart(void) interrupt 4
{
uchar cdd;
if(RI)
{
RI=0;
cdd=SBUF;
if(cdd==0xaa)
{
ISP_CONTR=0x60;//soft reset, start from ISP monitoring area
}
else if(cdd==0x55)
{
ISP_CONTR=0x20; //soft reset, start from user program area
}
else
{
senddata(cdd);
}
}
else
{
TI=0;
}
}
In addition, you need to customize the download settings in the stc download software to complete the operation video.
http://v.youku.com/v_show/id_XMTk2MTE5MTgw.html
It can be seen from the above that it is quite troublesome, so is there a simpler method? From the above video, we know that as long as the address 0xe7 is assigned 0x60, the function of downloading the program can be completed. Then I thought, the stc download software uses the serial port, and the serial port must be used to send data to the microcontroller, and the microcontroller receiving pin is P3^0, so we only need to detect whether there is a change in the level of this pin. If there is a change, then assign 0x60 to the address 0xe7, and the automatic download command will be completed. With an idea, I started to verify. After debugging, the result was successful, indicating that I have only tested STC89C52RC. Please test whether other chips are feasible. The following is a complete program. No settings are required in the stc download software, just download the program as usual.
/*** Another simpler method for STC MCU to download programs without power off ******************************************************************
**Program function: STC MCU to download programs without power off
**Chip model: STC89C52RC
**Crystal frequency: 11.0592M
**Date of writing: November 23, 2010
**Writer: wang QQ: 349259818 Email: hongfadg@163.com
**Remarks:
*******************************************************************/
//The following are the required header files
//#include
//#include
//#include
//#include
#include
//Define keywords for easy use
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sfr iap=0xe7; //Define download command
sbit p30=P3^0; //Serial port receiving pin
/* Main function
****************************************************************
**Function prototype: main()
**Function function:
**Input parameters: None
**Output parameters: None
**Remarks: Complete the main functions of the program
*******************************************************************/
main()
{
while(1) //Main loop
{
if(!p30) //Judge whether there is data in the serial port
{
iap=0x60; //Execute the command for automatic download
}
}
}
Previous article:stc single chip computer uninterruptible power download program
Next article:ECG signal simulation program based on stc12c56
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [RVB2601 Creative Application Development] 1. Unboxing and running FreeRTOS examples
- What types of consumer electronics are PCB boards suitable for?
- DSP200050006000 Series
- Three-phase AC-DC conversion circuit (Question B)
- Found the old 6-layer board.
- Battery Formation - Infineon helps you break through bottlenecks
- Constant current source circuit composed of transistor, diode and operational amplifier
- Transfer - Use diode design to protect sensitive RF circuits and components from large input signals
- Jeston nano uses Yolov4 to train its own data set (one type of object)
- MCU IO