【正文】
}}附錄三 中英文資料The General Situation of AT89C51Chapter 1 The application of AT89C51Microcontrollers are used in a multitude of mercial applications such as modems, motorcontrol systems, air conditioner control systems, automotive engine and among others. The high processing speed and enhanced peripheral set of these microcontrollers make them suitable for such highspeed eventbased applications. However, these critical application domains also require that these microcontrollers are highly reliable. The high reliability and low market risks can be ensured by a robust testing process and a proper tools environment for the validation of these microcontrollers both at the ponent and at the system level. Intel Platform Engineering department developed an objectoriented multithreaded test environment for the validation of its AT89C51 automotive microcontrollers. The goals of this environment was not only to provide a robust testing environment for the AT89C51 automotive microcontrollers, but to develop an environment which can be easily extended and reused for the validation of several other future microcontrollers. The environment was developed in conjunction with Microsoft Foundation Classes (AT89C51). The paper describes the design and mechanism of this test environment, its interactions with various hardware/software environmental ponents, and how to use AT89C51. IntroductionThe 8bit AT89C51 CHMOS microcontrollers are designed to handle highspeed calculations and fast input/output operations. MCS 51 microcontrollers are typically used for highspeed event control systems. Commercial applications include modems, motorcontrol systems, printers, photocopiers, air conditioner control systems, disk drives, and medical instruments. The automotive industry use MCS 51 microcontrollers in enginecontrol systems, airbags, suspension systems, and antilock braking systems (ABS). The AT89C51 is especially well suited to applications that benefit from its processing speed and enhanced onchip peripheral functions set, such as automotive powertrain control, vehicle dynamic suspension, antilock braking, and stability control applications. Because of these critical applications, the market requires a reliable costeffective controller。}Format(electricity, e)Format(remnant, r)showstring( 0x0100,0, e)。}else {P1_0=0。if(electricity==0){P1_0=1。}else showstring( 0x0100,0, string[5]。write_IICC(0x02 , 0 )。else showstring( 0x0100,0, string[3])。remnant= remnant+ Random_Readc( 0x01)。 If(P1_5==1){showstring( 0x0100,0, string[2])。While( 1 ){ if(P1_2==0 ) { delay( 1 )。remnant= Random_Read( 0x02 )。showstring( 0x0100,0, string[1])。 TMOD=0x03。 IP=0x01。p1_6=1。Intialize_LCD( )。sbit P1_0=P1^0。 unchar *string[]={“l(fā)ow power”,”electrograph”,”reading”,”ok”,”emport”,”wrong card”}。Void write_IIC(0x03 , count )。} ****************************************************************//掉電中斷(INT0)Void EX_INT0( ) interrupt 0{ Void write_IIC( 0x01 , electricity )。 electricity++。}****************************************************************//定時(shí)器0中斷Void T0_INT( ) intrerrpt 1{ count++。 stop( )。 write_A_Byte( 0xa0 )。 Return d。 NO_ACK( )。 write_A_Byte( 0xa1 )。} Unchar Read_Current( ){ Unchar d。 SCL=0。 b=1。 i8。}Unchar Read_A_Byte( ){ Unchar i, b。 stop( )。 write_A_Byte( addr )。}Void write_IIC( unchar addr ,unchar dat ){ Start( )。 SCL=0。 SCL=1。 SDA=CY。 i8。}Void write_A_Byte( unchar b ){ Unchar i。 SCL=0。 SCK=1。 SDA=1。 NOP4( )。}void RASK ( ){ SDA=1。 SCL=0。 NOP4( )。} void stop ( ){ SDA=0。 NOP4( )。 NOP4( )。void start ( ){ SDA=1。}sbit SDA=P3^0。 stop( )。 write_A_Bytec( 0xa0 )。 Return d。 NO_ACKC( )。 write_A_Bytec( 0xa1 )。} Unchar Read_Currentcc( ){ Unchar d。 SCLC=0。 b=1。 i8。}Unchar Read_A_Bytec( ){ Unchar i, b。 stopc( )。 write_A_Bytec( addr )。}Void write_IICC( unchar addr ,unchar dat ){ Startc( )。 SCLC=0。 SCLC=1。 SDAC=CY。 i8。}Void write_A_Bytec( unchar b ){ Unchar i。 SCLC=0。 SCKC=1。 SDAC=1。 NOP4( )。}void RASKC ( ){ SDAC=1。 SCLC=0。 NOP4( )。} void stopc ( ){ SDAC=0。 NOP4( )。 NOP4( )。void startc ( ){ SDAC=1。}sbit SDAC=P1^3。 _NOP_。 }****************************************************************// define NOP4( ) { _NOP_。a[2]=((d%1000)%100)/10+’0’。}}Void format ( unchar d, unchar*a) { a[0]=d/1000+’0’。 i16。 If (y==1) write_LCD_mand ( 0xc0|x)。} Void showstring( unchar x,unchar y,unchar *str) { unchar i=0。 void write_LCD_mand ( 0x0c) 。 void write_LCD_mand ( 0x06) 。 void write_LCD_mand ( 0x01) 。}void Intialize_LCD ( ){ void write_LCD_mand ( 0x38) 。 Delay( 1 ) 。 P0=dat。 RW=0。}void write_LCD_data ( unchar dat ) //寫LCD命令數(shù)據(jù){ LCD_Busy_wait ( ) 。 Delay( 1 ) 。 P0=cmd。 RW=0。 }void write_LCD_mand ( unchar cmd ) //寫LCD命令{ LCD_Busy_wait ( ) 。0x08 ) ==0x08 。 return state 。 EN =0。 //開始讀 Delay ( 1 ) 。 // 寄存器選擇 RW=1。}unchar Read_LCD_state ( ){ unchar state 。 i12。void Delay ( uint ms ) // 延時(shí){ unchar i。 sbit P1_5=P1^5。 sbit EN =P2^2。最后衷心感謝在百忙之中評(píng)閱論文和參加答辯的各位專家、教授!附錄一 總體電路圖附錄二 部分程序************************************************************ ************// include include include unchar unsigned char include uint unsigned int sbit RS =P2^0。在本次設(shè)計(jì)之后,我們基本上獲得了預(yù)期的收獲,有效的達(dá)到了畢業(yè)設(shè)計(jì)的目的和要求,完成了設(shè)計(jì)的任務(wù)。在培養(yǎng)運(yùn)用專業(yè)知識(shí)、分析和解決實(shí)際問(wèn)題的能力,科學(xué)研究的思維能力、探究能力和創(chuàng)新能力上,有著積極地促進(jìn)作用。由于本次畢業(yè)設(shè)計(jì)所涉及到的理論知識(shí)多、技能要求高、工作范圍廣、綜合性強(qiáng),我得到了全面鍛煉。XXX老師孜孜不倦探索及忘我工作之舉是我學(xué)習(xí)的模范。設(shè)計(jì)期間,我學(xué)到:治學(xué)務(wù)必嚴(yán)謹(jǐn)、思維務(wù)必開闊、科研務(wù)必創(chuàng)新。參考文獻(xiàn)[1] 馬忠梅等,單片機(jī)的C語(yǔ)言應(yīng)用程序設(shè)計(jì)(第四版). [2] 馮文旭微處理器受到干擾,I/O口狀態(tài)可能改變,比如電脈沖輸入口若改變?yōu)檩敵鰬B(tài),會(huì)造成用戶用了電,但微處理器確檢測(cè)不到的可能,所以周期性的重新定義I/O的輸入/輸出狀態(tài),對(duì)于干擾環(huán)境下運(yùn)行的電度表是有好處的。卡插入檢測(cè)要去抖動(dòng),要有卡短路檢測(cè),可進(jìn)行多一次的卡復(fù)位操作,卡流水號(hào),密碼