stc免断电下载,关键就是这段代码,调用方式详见附件
代码:
- #ifndef __IAP_H_
- #define __IAP_H_
- #include "reg52.H"
- //sfr STC_CONTR=0xe7; //STC89C52
- sfr STC_CONTR=0xC7; //STC12C5A
- sbit STC_Reset=P3^0;
- //免断电下载程序
- void Download(void) //(按复位下载程序,Download();放在main函数最开始)
- { //如果是自动下载程序(不用按复位键)
- // unsigned int i=5000;//注释 unsigned int i=5000; 和 while(i--)
- // while(i--) //并且把Download()放在main函数的while循环中
- if(!STC_Reset)
- STC_CONTR=0x60;
- }
- #endif
完整代码下载: