I have seen some examples of STC microcontrollers downloading programs without powering off on the Internet. However, they all require serial port interrupts to complete. The following is a program snippet
To illustrate
Add serial port initialization code and serial port interrupt code to the debugging program to achieve 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 Automatic Downloader
Next article:Simple use of 12864 LCD with font library
- 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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- About to leave, pack up and sell
- 2G Microstrip Power Divider Simulation Verification Sharing
- [N32L43X Review] 8. FreeRTOS Porting
- Award-winning survey - electronic engineers' component purchasing channels
- CLUE DICE
- [RISC-V MCU CH32V103 Review] + Timer Test and System Summary
- Bluetooth Low Energy (BLE) peripheral mode (peripheral) - using BLE as a server
- The problem of the total distortion increasing after the signal passes through the op amp filter circuit
- FPGA implementation of the design of RU algorithm encoder (LDPC encoder)
- [NXP Rapid IoT Review] + Laptop Bluetooth Interaction with Rapid IOT