《STC单片机内部FLASH读写程序(最新整理)》由会员分享,可在线阅读,更多相关《STC单片机内部FLASH读写程序(最新整理)(6页珍藏版)》请在人人文库网上搜索。
1、STC 单片机内部 FLASH 读写程序(http:/control.blog.sina.com.cn/admin/article/article_add.php)电子伙伴 发表于 2006-4-11 16:26:001推 荐/i nclude STC89C51.h/i nclude #define ERROR0#define OK1#define WAIT_TIME0x00/mcu clock 40mhz/#define WAIT_TIME0x01/mcu clock 20mhz/#define WAIT_TIME0x02/mcu clock 10mhz/#define WAIT_TIME0。
2、x03/mcu clock 5mhz#define HOUR0x8000 #define MINUTE 0x8001void ISP_EN(void)EA = 0;/关中断ISP_CONTR = ISP_CONTR & 0x18;/ 0001,1000ISP_CONTR = ISP_CONTR | WAIT_TIME;ISP_CONTR = ISP_CONTR | 0x80;/ 1000,0000void ISP_DI(void)ISP_CONTR = ISP_CONTR & 0x7f;/ 0111,1111 ISP_TRIG = 0x00;EA=1;/ 开中断unsigned char By。
3、te_read(unsigned int byte_addr)ISP_ADDRH = (unsigned char)(byte_addr 8); ISP_ADDRL = (unsigned char)(byte_addr & 0x00ff);ISP_CMD= ISP_CMD & 0xf8;/ 1111,1000ISP_CMD= ISP_CMD | 0x01;/ 0000,0001字节读数据存储区ISP_EN();ISP_TRIG = 0x46; ISP_TRIG = 0xb9;_nop_();ISP_DI();return (ISP_DATA);void Sector_erase(unsign。
4、ed int Sector_addr)unsigned char addre;addre= (unsigned char)(Sector_addr 8);/ 1111,1110,0000,0000; 取扇区地址ISP_ADDRHISP_ADDRL= addre&0xfe;= 0x00;ISP_CMD =ISP_CMD & 0xf8;/ 1111,1000ISP_CMD =ISP_CMD | 0x03;/ 0000,0011扇区擦除数据存储区ISP_EN();ISP_TRIG = 0x46;/ 触发 ISP_IAP 命令ISP_TRIG = 0xb9;/ 触发 ISP_IAP 命令_nop_()。
5、;ISP_DI();void Byte_program(unsigned int byte_addr, unsigned char DataBuf)ISP_ADDRH = (unsigned char)(byte_addr 8); ISP_ADDRL = (unsigned char)(byte_addr & 0x00ff);ISP_CMD= ISP_CMD & 0xf8;/ 1111,1000ISP_CMD= ISP_CMD | 0x02;/ 0000,0010字节编程数据存储区ISP_DATA = DataBuf;ISP_EN();ISP_TRIG = 0x46;/ 触发 ISP_IAP 。
6、命令ISP_TRIG = 0xb9;/ 触发 ISP_IAP 命令_nop_();ISP_DI();unsigned char ByteProgramVerify(unsigned int byte_addr, unsigned char DataBuf)ISP_ADDRH = (unsigned char)(byte_addr 8); ISP_ADDRL = (unsigned char)(byte_addr & 0x00ff);ISP_CMD=ISP_CMD &0xf8;/ 1111,1000ISP_CMD=ISP_CMD |0x02;/0000,0010字节编程数据存储区ISP_DATA。
7、=DataBuf;ISP_EN();ISP_TRIG ISP_TRIG_nop_();=0x46;0xb9;ISP_DATA=0x00;ISP_CMD=ISP_CMD &0xf8;/ 1111,1000ISP_CMD=ISP_CMD |0x01;/ 0000,0001ISP_TRIG = 0x46;/ 触发 ISP_IAP 命令ISP_TRIG = 0xb9;/ 触发 ISP_IAP 命令_nop_();ISP_DI();if(ISP_DATA=DataBuf) return OK; else return ERROR;“”“”At the end, Xiao Bian gives you a。
8、 passage. Minand once said, people who learn to learn are very happy people. In every wonderful life, learning is an eternal theme. As a professional clerical and teaching position, I understand the importance of continuous learning, life is diligent, nothing can be gained, only continuous learning 。
9、can achieve better self. Only by constantly learning and mastering the latest relevant knowledge, can employees from all walks of life keep up with the pace of enterprise development and innovate to meet the needs of the market. This document is also edited by my studio professionals, there may be errors in the document, if there are errors, please correct, thank you。