【正文】
r Data Book,2004[J].612附錄1中文譯文STC89C52芯片簡介在STC89C52單片機是一種低功耗,高性能CMOS 8位單片機與8KB的閃存和可擦除可編程只讀存儲器(PEROM)。該設備是采用Atmel的高密度非易失性內(nèi)存技術和符合工業(yè)標準的80C51的和80C52指令集和引腳。片上閃存可程式記憶體將重新在系統(tǒng)或傳統(tǒng)的非易失性內(nèi)存程序員。通過結合一個多功能的8位CPU與Flash的單片芯片,STC公司STC89C52是一個功能強大,提供了一個高度靈活的和符合成本效益的解決許多嵌入式控制應用的單片機。 在STC89C52單片機提供了以下標準功能:8KB的閃存,256B的RAM ,32 I/ O線,3個16位定時器/計數(shù)器,一個6向量兩個級別的中斷結構,一個全雙工串行端口,對片上振蕩器和時鐘電路。此外,STC89C52的目的是靜態(tài)的邏輯運行到零頻率和支持兩種軟件可選節(jié)電模式。在閑置模式停止的CPU同時使內(nèi)存,定時器/計數(shù)器,串行接口和中斷系統(tǒng)繼續(xù)運作。在電源關閉模式節(jié)省了內(nèi)存的內(nèi)容,但凍結振蕩器,停用所有其他芯片功能,直到下一次硬件復位。引腳功能說明VCC:電源電壓GND:地P0口:P0口是一組8位漏極開路型雙向I/O口,也即地址/數(shù)據(jù)總線復用口。作為輸出口用時,每位能驅動8個TTL邏輯門電路,對端口寫“1”可作為高阻抗輸入端用。在方位外部數(shù)據(jù)存儲器或程序存儲器時,這組口線分時轉換地址(低8位)和數(shù)據(jù)總線復用,在訪問期間激活內(nèi)部上拉電阻。在Flash編程時,P0口接受指令字節(jié),而在程序校驗時,輸出指令字節(jié),校驗時,要求外接上拉電阻。P1口:P1是一個帶內(nèi)部上拉電阻的8位雙向I/O口,P1的輸出緩沖級可驅動(吸收或輸出電流)4個TTL邏輯門電路。對端口寫“1”,通過內(nèi)部的上拉電阻把端口拉到高電平,此時可做輸出入口。做輸入口使用時,因為內(nèi)部存在上拉電阻,某個引腳被外部信號拉低時會輸出一個電流。Flash編程和程序校驗期間,P1接收低8位地址。P2口:P2是一個帶內(nèi)部上拉電阻的8位雙向I/O端口。P2口輸出緩沖器可以可驅動(吸收或輸出電流)4個TTL邏輯門電路。對端口寫“1”,通過內(nèi)部的上拉電阻把端口拉到高電平,此時可做輸出入口。做輸入口使用時,因為內(nèi)部存在上拉電阻,某個引腳被外部信號拉低時會輸出一個電流。Flash編程和程序校驗期間,P2接收低8位地址。P3口:P3是一個帶內(nèi)部上拉電阻的8位雙向I/O端口。P3口輸出緩沖器可以可驅動(吸收或輸出電流)4個TTL邏輯門電路。對端口寫“1”,通過內(nèi)部的上拉電阻把端口拉到高電平,此時可做輸出入口。做輸入口使用時,因為內(nèi)部存在上拉電阻,某個引腳被外部信號拉低時會輸出一個電流。Flash編程和程序校驗期間,P3接收低8位地址。STC89C52的主要性能參數(shù)與MCS51產(chǎn)品指令系統(tǒng)完全兼容8K字節(jié)在系統(tǒng)編程(ISP)Flash閃速存儲器1000次擦寫周期—全靜態(tài)工作模式:0Hz—24MHz三級程序加密鎖256X8字節(jié)內(nèi)部RAM32個可編程I/O口線3個16位定時/計數(shù)器8個中斷源全雙工串行UART通道低功耗空閑和掉電模式附錄2英文原文STC89C52 DescriptionThe STC89C52 is a lowpower, highperformance CMOS 8bit microputer with 8Kbytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using STC’s highdensity nonvolatile memory technology and is patible with the industrystandard 80C51 and 80C52 instruction set and pinout.The onchip Flash allows the program memory to be reprogrammed insystem or by a conventional nonvolatile memory programmer. By bining a versatile 8bit CPU with Flash on a monolithic chip, the Atmel STC89C52 is a powerful microputerwhich provides a highlyflexible and costeffective solution to many embedded control applications.The STC89C52 provides the following standard features: 8Kbytes of Flash, 256 bytes of RAM, 32 I/O lines, three 16bit timer/counters, a sixvector twolevel interrupt architecture, a fullduplex serial port, onchip oscillator, and clock circuitry. In addition, the STC89C52 is designed with static logicfor operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning.The Powerdown mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next hardware reset.Pin DescriptionVCC Supply voltage.GND Ground.Port 0Port 0 is an 8bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs.Port 1Port 1 is an 8bit bidirectional I/O port with internal pullups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will sourcecurrent (IIL) because of the internal pullups.Port 2Port 2 is an 8bit bidirectional I/O port with internal pullups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will sourcecurrent (IIL) because of the internal pullups.Port 3Port 3 is an 8bit bidirectional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will sourcecurrent (IIL) because of the pullups.The main performance parameters STC89C52Compatible with MCS51 Products8K Bytes of InSystem Reprogrammable Flash MemoryEndurance: 1,000 Write/Erase CyclesFully Static Operation: 0 Hz to 24 MHz operating voltage rangeThreelevel Program Memory Lock256 x 8bit Internal RAM32 Programmable I/O LinesThree 16bit Timer/CountersEight Interrupt SourcesProgrammable Serial ChannelLowpower Idle and Powerdown Modes附錄3 圖附31整體硬件實物圖 圖附32主硬件實物圖附錄4主要代碼include includeinclude define uchar unsigned chardefine uint unsigned intvoid delay(int)。void Write_LCD_Command(uchar)。void Write_LCD_Data(uchar)。void Initialize_LCD()。void reset_password()。void read_password()。void read_new_password()。judge_password()。judge_new_password()。void delete_word()。 void display()。uchar O_password_num。 //原密碼位數(shù)uchar R_password_num。 //讀入密碼位數(shù) uchar Z_password_num。 //暫存修改密碼位數(shù)uchar code tab[]={0123456789*ABCD}。uchar code tab1[]={ Enter Password }。uchar code tab2[]={ Password OK }。uchar code tab3[]={ Password ERROR }。uchar code tab4[]={ Old Password }。uchar code tab5[]={ New Password }。uchar code tab6[]={ Enter Again }。uchar code tab7[]={ Both Different }。uchar code tab8[]={ Reset OK }。uchar code tab9[]={ OPEN THE DOOR }。uchar code tab10[]={ CLOSE THE DOOR }。uchar code yanma[]={************}。uchar O_password[6]={1,2,3,4,5,6}。 //初始密碼uchar R_password[6]。 //記錄讀入密碼uchar Z_password[6]。 //暫存修改密碼sbit LCDRS = P1^2。//設置端口sbit LCDRW = P1^1。//設置端口sbit LCDEN = P1^0。//設置端口sbit beep = P3^3。//蜂鳴器sbit P34=P3^4。//步進電機端口設置sbit P35=P3^5。sbit P36=P3^6。sbit P37=P3^7。sbit key1=P1^3。sbit key2=P1^4。uchar hang,lie,zd=60。 //定義全局變量//毫秒延時void delayms(int ms){ uchar i。 while(ms) { for(i=0。ii++) { _nop_()。 _nop_()。