There are two program areas in the STC microcontroller, the user program area and the ISP program area.
After the microcontroller is powered on (cold start, not external manual reset or watchdog reset), the ISP program will be run first to detect whether there is a legal download command flow, which takes tens to hundreds of milliseconds.
If there is no legitimate download command stream, the user program is run immediately.
If there is a legitimate download command stream, the ISP monitoring program starts to communicate with the ISP download software, and the software also enters the programming mode and sends the program code to the monitoring program. The monitoring program receives the program code and writes it into the user program area.
After programming is completed and the program is successfully verified, the user program takes effect immediately and starts running.
If the IAP_CONTR register is not set in the software through the serial port with the host computer (such as the following program), when STC-ISP tries to handshake with the MCU, it will continuously send the "0x7F" signal from the serial port at the baud rate in the "minimum baud rate" setting item until the power-on cold start (or soft reset to ISP) detects the download command flow for tens to hundreds of milliseconds, and then stops sending the "0x7F" signal.
If IAP_CONTR is set, the corresponding setting related commands will be executed.
#include unsigned char RevData; //void UartInit() //{ // PCON &= 0x7F; // SCON = 0x50; //AUXR &= 0xBF; // AUXR &= 0xFE; // TMOD &= 0x0F; // TMOD |= 0x20; // TL1 = 0xFD; //TH1 = 0xFD; //ET1 = 0; // TR1 = 1; //} void UartInit() { AUXR &= 0xF7; S2CON = 0x50; AUXR &= 0xFB; BRT = 0xFD; AUXR |= 0x10; } void main() { UartInit(); EA = 1; ES = 1; P0 = 0; while(1); } void Uart() interrupt 4 { if(RI) { RI = 0; RevData = SBUF; if(RevData == 0x0a) { IAP_CONTR=0x60; } } if(TI) {} }
Previous article:Using the PWM function of the microcontroller to realize DAC with the help of filters
Next article:I2C communication timing problem of 89 and 12 microcontrollers
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- Use transistor + MOS tube to control battery output
- Contemporary IoT smart antenna design trends | Review TE's exciting live broadcast, write a comment and win a gift!
- VLSI Digital Signal Processing Systems: Design and Implementation
- A foreign guy pranked: using ESP32 microcontroller disguised as GPU to infect his friend's computer with "ransomware"
- 13 Rules You Must Read for RF Circuit Power Supply Design
- Agilent6684A power supply maintenance method - Antai Instrument Maintenance
- General frequency converter technology of DSP
- Comparison table of domestic 32-bit MCU and ST, GD compatible models
- Foxconn insider steals iPhone parts and resells them for 300 million yuan, alarming Cook, Apple is investigating
- [MM32 eMiniBoard Review] Part 2: Environment Construction and Program Burning