【正文】
1800H19FF第六扇區(qū):1A00H1BFF第七扇區(qū):1C00H1DFF第八扇區(qū):1E00H1FFF*****************//********STC89C52扇區(qū)分布*******第一扇區(qū):2000H21FF第二扇區(qū):2200H23FF第三扇區(qū):2400H25FF第四扇區(qū):2600H27FF第五扇區(qū):2800H29FF第六扇區(qū):2A00H2BFF第七扇區(qū):2C00H2DFF第八扇區(qū):2E00H2FFF*****************/define RdCommand 0x01 //定義ISP的操作命令define PrgCommand 0x02define EraseCommand 0x03 define Error 1define Ok 0define WaitTime 0x01 //定義CPU的等待時間sfr ISP_DATA=0xe2。 //寄存器申明sfr ISP_ADDRH=0xe3。sfr ISP_ADDRL=0xe4。sfr ISP_CMD=0xe5。sfr ISP_TRIG=0xe6。sfr ISP_CONTR=0xe7。/* ================ 打開 ISP,IAP 功能 ================= */void ISP_IAP_enable(void){ EA = 0。 /* 關中斷 */ ISP_CONTR = ISP_CONTR amp。 0x18。 /* 0001,1000 */ ISP_CONTR = ISP_CONTR | WaitTime。 /* 寫入硬件延時 */ ISP_CONTR = ISP_CONTR | 0x80。 /* ISPEN=1 */}/* =============== 關閉 ISP,IAP 功能 ================== */void ISP_IAP_disable(void){ ISP_CONTR = ISP_CONTR amp。 0x7f。 /* ISPEN = 0 */ ISP_TRIG = 0x00。 EA = 1。 /* 開中斷 */}/* ================ 公用的觸發(fā)代碼 ==================== */void ISPgoon(void){ ISP_IAP_enable()。 /* 打開 ISP,IAP 功能 */ ISP_TRIG = 0x46。 /* 觸發(fā)ISP_IAP命令字節(jié)1 */ ISP_TRIG = 0xb9。 /* 觸發(fā)ISP_IAP命令字節(jié)2 */ _nop_()。}/* ==================== 字節(jié)讀 ======================== */unsigned char byte_read(unsigned int byte_addr){ EA = 0。 ISP_ADDRH = (unsigned char)(byte_addr 8)。/* 地址賦值 */ ISP_ADDRL = (unsigned char)(byte_addr amp。 0x00ff)。 ISP_CMD = ISP_CMD amp。 0xf8。 /* 清除低3位 */ ISP_CMD = ISP_CMD | RdCommand。 /* 寫入讀命令 */ ISPgoon()。 /* 觸發(fā)執(zhí)行 */ ISP_IAP_disable()。 /* 關閉ISP,IAP功能 */ EA = 1。 return (ISP_DATA)。 /* 返回讀到的數(shù)據(jù) */}/* ================== 扇區(qū)擦除 ======================== */void SectorErase(unsigned int sector_addr){ unsigned int iSectorAddr。 iSectorAddr = (sector_addr amp。 0xfe00)。 /* 取扇區(qū)地址 */ ISP_ADDRH = (unsigned char)(iSectorAddr 8)。 ISP_ADDRL = 0x00。 ISP_CMD = ISP_CMD amp。 0xf8。 /* 清空低3位 */ ISP_CMD = ISP_CMD | EraseCommand。 /* 擦除命令3 */ ISPgoon()。 /* 觸發(fā)執(zhí)行 */ ISP_IAP_disable()。 /* 關閉ISP,IAP功能 */}/* ==================== 字節(jié)寫 ======================== */void byte_write(unsigned int byte_addr, unsigned char original_data){ EA = 0。// SectorErase(byte_addr)。 ISP_ADDRH = (unsigned char)(byte_addr 8)。 /* 取地址 */ ISP_ADDRL = (unsigned char)(byte_addr amp。 0x00ff)。 ISP_CMD = ISP_CMD amp。 0xf8。 /* 清低3位 */ ISP_CMD = ISP_CMD | PrgCommand。 /* 寫命令2 */ ISP_DATA = original_data。 /* 寫入數(shù)據(jù)準備 */ ISPgoon()。 /* 觸發(fā)執(zhí)行 */ ISP_IAP_disable()。 /* 關閉IAP功能 */ EA =1。} endif 外文原文Design of the Temperature Control System Based on AT89S51ABSTRACT The principle and functions of the temperature control system based on microcontroller AT89S51 are studied, and the temperature measurement unit consists of the 1Wire bus digital temperature sensor DS18B20. The system can be expected to detect the preset temperature, display time and save monitoring data. An alarm will be given by system if the temperature exceeds the upper and lower limit value of the temperature which can be set discretionarily and then automatic control is achieved, thus the temperature is achieved monitoring intelligently within a certain range. Basing on principle of the system, it is easy to make a variety of other nonlinear control systems so long as the software design is reasonably changed. The system has been proved to be accurate, reliable and satisfied through field practice. KEYWORDS: AT89S51。 microcontroller。 DS18B20。 temperatureI. INTRODUCTION Temperature is a very important parameter in human life. In the modern society, temperature control (TC) is not only used in industrial production, but also widely used in other fields. With the improvement of the life quality, we can find the TC appliance in hotels, factories and home as well. And the trend that TC will better serve the whole society, so it is of great significance to measure and control the temperature. Based on the AT89S51 and temperature sensor DS18B20, this system controls the condition temperature intelligently. The temperature can be set discretionarily within a certain range. The system can show the time on LCD, and save monitoring data。 and automatically control the temperature when the condition temperature exceeds the upper and lower limit value. By doing so it is to keep the temperature unchanged. The system is of high antijamming, high control precision and flexible design。 it also fits the rugged environment. It is mainly used in people39。s life to improve the quality of the work and life. It is also versatile, so that it can be convenient to extend the use of the system. So the design is of profound importance. The general design, hardware design and software design of the system are covered. II. SYSTEM GENERAL DESIGN The hardware block diagram of the TC is shown in Fig. 1. The system hardware includes the microcontroller, temperature detection circuit, keyboard control circuit, clock circuit, Display, alarm, drive circuit and external RAM. Based on the AT89S51, the DS18B20 will transfer the temperature signal detected to digital signal. And the signal is sent to the microcontroller for processing. At last the temperature value is showed on the LCD 12232F. These steps are used to achieve the temperature detection. Using the keyboard interface chip HD7279 to set the temperature value, using the microcontroller to keep a certain temperature, and using the LCD to show the preset value for controlling the temperature. In addition, the clock chip DS1302 is used to show time and the external RAM 6264 is used to save the monitoring data. An alarm will be given by buzzer in time if the temperature exceeds the upper and lower limit value of the temperature. III. HARDWARE DESIGN A. Microcontroller The AT89S51 is a lowpower, highperformance C