Another simpler method to download programs without powering off STC microcontrollers

Publisher:代码漫游者Latest update time:2012-08-04 Source: 61ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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
}
}

}

Reference address:Another simpler method to download programs without powering off STC microcontrollers

Previous article:STC Automatic Downloader
Next article:Simple use of 12864 LCD with font library

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号