毛片在线视频观看,一级日韩免费大片,在线网站黄色,澳门在线高清一级毛片

薈聚奇文、博采眾長(zhǎng)、見賢思齊
當(dāng)前位置:公文素材庫(kù) > 計(jì)劃總結(jié) > 工作總結(jié) > 單片機(jī)實(shí)訓(xùn)總結(jié)

單片機(jī)實(shí)訓(xùn)總結(jié)

網(wǎng)站:公文素材庫(kù) | 時(shí)間:2019-05-28 03:19:15 | 移動(dòng)端:單片機(jī)實(shí)訓(xùn)總結(jié)

單片機(jī)實(shí)訓(xùn)總結(jié)

單片機(jī)心得總結(jié)

通過(guò)這一個(gè)學(xué)期的單片機(jī)學(xué)習(xí),我收獲了很多關(guān)于單片機(jī)的知識(shí),并且這些知識(shí)和日常的生活息息相關(guān)。了解了一些簡(jiǎn)單程序的錄入,LED顯示器、鍵盤、和顯示器的應(yīng)用和原理。

LED顯示器:LED顯示器是由發(fā)光二管組成顯示字段的器件。通常的8段LED顯示器是由8個(gè)發(fā)光二極管組成,LED顯示器分共陽(yáng)極和共陰極兩種。有段選碼和和位選碼。當(dāng)LED顯示器每段的平均電流位5MA時(shí),就有較滿意的亮度,一般選擇斷碼5-10MA電流;位線的電流應(yīng)選擇40-80MA。LED顯示器的顯示方式有動(dòng)態(tài)和靜態(tài)兩種。7289A芯片是具有SPI串行接口功能的顯示鍵盤控制芯片,它可同時(shí)取得8位共陰極數(shù)碼管和64個(gè)鍵的鍵盤矩陣。7289A的控制指令分為兩類:8位寬度的單字節(jié)指令和16位寬度雙字節(jié)指令;還有閃爍指令和消隱指令。7289A采用串行方式SPI總線與微處理器通信;7289A與AT89C52接口電路,在實(shí)際電路中無(wú)論接不接鍵盤,電路中連接到其各段上的8個(gè)100千歐的下拉電阻均不可以省去,如果不接鍵盤而只接顯示器可以省去8個(gè)10千歐電阻,若僅接鍵盤而不接顯示器,可省去串入DP及SA-SG連線的8個(gè)220歐電阻,7289A還需要外接晶體振蕩電路。液晶顯示器簡(jiǎn)稱LCD,其顯示原理是用經(jīng)過(guò)處后的液晶具有能改變光線傳輸方向的特性,達(dá)到顯示字符和圖形的目的。最簡(jiǎn)單的筆段式液晶顯示器類似于LCD顯示器,可以顯示簡(jiǎn)單的字符和數(shù)字,而目前大量使用的是點(diǎn)陣式LCD顯示器,既可以顯示字符和數(shù)字也可以顯示漢字和圖形。如果把LCD顯示屏、背光可變電源、接口控制邏輯、驅(qū)動(dòng)集成芯片等部件構(gòu)成一個(gè)整體,是的與CPU接口十分方便。

鍵盤:鍵盤是最常見的計(jì)算機(jī)輸入設(shè)備,它廣泛應(yīng)用于微型計(jì)算機(jī)和各種終端設(shè)備上。計(jì)算機(jī)操作者通過(guò)鍵盤向計(jì)算機(jī)輸入各種指令、數(shù)據(jù),指揮計(jì)算機(jī)的工作。按照鍵盤的工作原理和按鍵方式的不同,可以劃分為四種:機(jī)械式鍵盤采用類似金屬接觸式開關(guān),工作原理是使觸點(diǎn)導(dǎo)通或斷開,具有工藝簡(jiǎn)單、噪音大、易維護(hù)的特點(diǎn)。塑料薄膜式鍵盤鍵盤內(nèi)部共分四層,實(shí)現(xiàn)了無(wú)機(jī)械磨損。其特點(diǎn)是低價(jià)格、低噪音和低成本,已占領(lǐng)市場(chǎng)絕大部分份額。導(dǎo)電橡膠式鍵盤觸點(diǎn)的結(jié)構(gòu)是通過(guò)導(dǎo)電橡膠相連。鍵盤內(nèi)部有一層凸起帶電的導(dǎo)電橡膠,每個(gè)按鍵都對(duì)應(yīng)一個(gè)凸起,按下時(shí)把下面的觸點(diǎn)接通。這種類型鍵盤是市場(chǎng)由機(jī)械鍵盤向薄膜鍵盤的過(guò)渡產(chǎn)品。無(wú)接點(diǎn)靜電電容式鍵盤使用類似電容式開關(guān)的原理,通過(guò)按鍵時(shí)改變電極間的距離引起電容容量改變從而驅(qū)動(dòng)編碼器。特點(diǎn)是無(wú)磨損且密封性較好。

按照按鍵方式的不同鍵盤可分為接觸式和無(wú)觸點(diǎn)式兩類。接觸式鍵盤就是我們通常所說(shuō)的機(jī)械式鍵盤,它又分為普通觸點(diǎn)式和干簧式。普通觸點(diǎn)式的兩個(gè)觸點(diǎn)直接接觸,從而使電路閉合,產(chǎn)生信號(hào);而干簧式鍵盤則是在觸點(diǎn)間加裝磁鐵,當(dāng)鍵按下時(shí),依靠磁力使觸點(diǎn)接觸,電路閉合。與普通觸點(diǎn)式鍵盤相比,干簧式鍵盤具有響應(yīng)速度快、使用壽命長(zhǎng)、觸點(diǎn)不易氧化等優(yōu)點(diǎn)。無(wú)觸點(diǎn)式鍵盤又分為電容式、霍爾式和觸摸式三種。其中電容式是我們最常用到的鍵盤類型,它的觸點(diǎn)之間并非直接接觸,而是當(dāng)按鍵按下時(shí),在觸點(diǎn)之間形成兩個(gè)串聯(lián)的平板電容,從而使脈沖信號(hào)通過(guò),其效果與接觸式是等同的。電容式鍵盤擊鍵時(shí)無(wú)噪聲,響應(yīng)速度快,但是價(jià)格很高一些。

顯示器:按照顯示器的顯示管分類CRT、LCD。按顯示色彩分類單色顯示器、彩色顯

示器。按大小分類通常有14寸、15寸、17寸和19寸,或者更大。顯示管的屏幕上涂有一層熒光粉,電子槍發(fā)射出的電子擊打在屏幕上,使被擊打位置的熒光粉發(fā)光,從而產(chǎn)生了圖像,每一個(gè)發(fā)光點(diǎn)又由“紅”“綠”“藍(lán)”三個(gè)小的發(fā)光點(diǎn)組成,這個(gè)發(fā)光點(diǎn)也就是一個(gè)象素。由于電子束是分為三條的,它們分別射向屏幕上的這三種不同的發(fā)光小點(diǎn),從而在屏幕上出現(xiàn)絢麗多彩的畫面。顯示器顯示畫面是由顯示卡來(lái)控制的。若仔細(xì)觀察顯示器上的文本或圖像是由點(diǎn)組成的,屏幕上點(diǎn)越多越密,則分辨率越高。

屏幕上相鄰兩個(gè)同色點(diǎn)的距離稱為點(diǎn)距,常見點(diǎn)距規(guī)格有0.31mm、0.28mm、0.25mm

等。顯示器點(diǎn)距越小,在高分辨率下越容易取得清晰的顯示效果。電子束采用光柵掃描方式,從屏幕左上角一點(diǎn)開始,向右逐點(diǎn)進(jìn)行掃描,形成一條水平線;到達(dá)最右端后,又回到下一條水平線的左端,重復(fù)上面的過(guò)程;當(dāng)電子束完成右下角一點(diǎn)的掃描后,形成一幀。此后,電子束又回到左上方起點(diǎn),開始下一幀的掃描。這種方法也就是常說(shuō)的逐行掃描顯示。而隔行掃描指電子束在掃描時(shí)每隔一行掃一線,完成一屏后再返回來(lái)掃描剩下的線,這與電視機(jī)的原理一樣。隔行掃描的顯示器比逐行掃描閃爍得更厲害,也會(huì)讓使用者的眼睛更疲勞。完成一幀所花時(shí)間的倒數(shù)叫垂直掃描頻率,也叫刷新頻率,比如60Hz、75Hz等。

通過(guò)這幾天的單片機(jī)的實(shí)訓(xùn),我在理論的基礎(chǔ)上更深刻的掌握了單片機(jī)的深層內(nèi)容及實(shí)際生活中的應(yīng)用,實(shí)訓(xùn)鍛煉了自己動(dòng)手能力和思維能力,還有在軟件方面的編程能力,讓我受益匪淺,同時(shí)也暴露出一些平時(shí)學(xué)習(xí)上的問(wèn)題,讓我深刻反思。這些問(wèn)題的發(fā)現(xiàn)將為我以后的學(xué)習(xí)和工作找明道路,查漏補(bǔ)缺為進(jìn)一步學(xué)習(xí)作好準(zhǔn)備。通過(guò)實(shí)訓(xùn),讓我懂得了如何編寫一些簡(jiǎn)單的程序,學(xué)會(huì)了如何制作單片機(jī)應(yīng)用程序,并且可以在今后的日常生活中靈活運(yùn)用。

擴(kuò)展閱讀:單片機(jī)實(shí)習(xí)總結(jié)

專業(yè)綜合實(shí)習(xí)總結(jié)

201*-201*(2)

專業(yè)班級(jí):電子信息工程0802學(xué)生學(xué)號(hào):0414080224學(xué)生姓名:

指導(dǎo)教師:張?jiān)、包長(zhǎng)春、馬崇霄、杜殿會(huì)實(shí)習(xí)時(shí)間:201*.6.20201*.7.15

機(jī)電工程學(xué)院

一、實(shí)習(xí)目的和意義

1、實(shí)習(xí)目的:

(1)利用單片機(jī)小系統(tǒng)實(shí)習(xí)板,掌握電路原理圖;

(2)通過(guò)對(duì)系統(tǒng)板的測(cè)試,了解系統(tǒng)板的工作原理及性能,掌握元器件及系統(tǒng)故障的排除方法;

(3)掌握程序編制及調(diào)試方法,完成系統(tǒng)初始化、存儲(chǔ)器操作、端口操作、模擬量采集、模擬量輸出、串口通訊、IIC、日歷時(shí)鐘芯片、鍵盤顯示等程序的編制及調(diào)試。

(4)通過(guò)單片機(jī)系統(tǒng)的調(diào)試、程序編制及運(yùn)行,掌握單片機(jī)系統(tǒng)的工作原理、開發(fā)方法和操作方法。2、實(shí)習(xí)意義:

電子技術(shù)和微型計(jì)算機(jī)的迅速發(fā)展,促進(jìn)了微型計(jì)算機(jī)測(cè)量和控制技術(shù)的迅速發(fā)展和廣泛應(yīng)用。微機(jī)測(cè)控技術(shù)的應(yīng)用已滲透到國(guó)民經(jīng)濟(jì)的各個(gè)部門?梢哉f(shuō),微機(jī)測(cè)控技術(shù)的應(yīng)用是產(chǎn)品提高檔次和推陳出新的有效途徑。創(chuàng)新精神和實(shí)踐能力是對(duì)新時(shí)期高素質(zhì)人才的基本要求。通過(guò)本實(shí)習(xí)不但可以掌握單片機(jī)軟、硬件的綜合調(diào)試方法,而且可以熟練掌握電路原理圖,激發(fā)對(duì)單片機(jī)智能性的探索精神,提高學(xué)生的綜合素質(zhì),培養(yǎng)學(xué)生應(yīng)用單片機(jī)實(shí)現(xiàn)對(duì)工業(yè)控制系統(tǒng)的設(shè)計(jì)、開發(fā)與調(diào)試的能力。在制作學(xué)習(xí)過(guò)程中,不但可以掌握軟、硬件的綜合調(diào)試方法,而且可以使學(xué)生對(duì)單片機(jī)智能性產(chǎn)生強(qiáng)烈的欲望。達(dá)到最大限度地掌握微機(jī)應(yīng)用技術(shù),軟件及接口設(shè)計(jì)和數(shù)據(jù)采集與處理的技能,培養(yǎng)電綜合實(shí)踐素質(zhì)的目。

二、實(shí)習(xí)內(nèi)容

1.熟悉“單片機(jī)課程實(shí)習(xí)”電路板,領(lǐng)會(huì)、掌握該電路板的設(shè)計(jì)原理及硬件布局。2.掌握單片機(jī)技術(shù)應(yīng)用平臺(tái)keil軟件的學(xué)習(xí)。

3.借助平臺(tái)軟件,學(xué)習(xí)開發(fā)板的使用,按照要求編制、調(diào)試出正確的匯編語(yǔ)言程序。4.學(xué)習(xí)適合本開發(fā)平臺(tái)軟件STC-ISP的在線單片機(jī)燒錄。

5.針對(duì)實(shí)習(xí)電路板的功能,編制、調(diào)試、編譯匯編語(yǔ)言程序,下載燒錄并在實(shí)驗(yàn)板上運(yùn)行,或利用軟件proteus進(jìn)行軟件仿真。

實(shí)現(xiàn)的功能:

1.led顯示模塊:?jiǎn)蜗蜓h(huán)流水led顯示、雙向循環(huán)流水led顯示、花樣流水燈的顯示,使用查表方法編制任意點(diǎn)亮歷程的實(shí)現(xiàn),使用軟件延時(shí);

2.數(shù)碼管顯示模塊:一位靜態(tài)數(shù)碼管顯示0到9和0到F、二位靜態(tài)數(shù)碼管顯示0到99、三位靜態(tài)數(shù)碼管顯示0到999、四位靜態(tài)數(shù)碼管顯示0到9999;陰極和陽(yáng)極四位動(dòng)態(tài)數(shù)碼管顯示;74LS驅(qū)動(dòng)4位靜態(tài)數(shù)碼管顯示;利用74HC595四位靜態(tài)數(shù)碼管顯示;使用串行靜態(tài)顯示和動(dòng)態(tài)掃描顯示兩種方式;

3.鍵盤模塊:利用4×4矩陣鍵盤按鍵對(duì)應(yīng)置數(shù)顯示“0~F”;使用鍵盤的行列掃描方式;

三、硬件介紹

(一)LED顯示模塊:

C21930pFU1XTAL1X1CRYSTALC118XTAL29RSTP0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD393837363534333221222324252627281011121314151617R11kC31uF29303130pF12345678PSENALEEAR251kP1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7AT89C51D7LED-REDD6LED-REDD5LED-REDD4LED-REDD3LED-REDD2LED-REDD1LED-REDD0LED-RED圖1流水燈顯示

C130pX1CRYSTALVCCC230pU119XTAL1P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD393837363534333221222324252627281011121314151617D1D2D3D4D5D6D7D8LED-REDR3R4200R5201*8XTAL2C31uF9LED-GREENRSTR21kLED-REDLED-REDR6201*00R151k293031PSENALEEAR7R8200LED-RED12345678P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7AT89C51LED-REDR9R10200LED-REDLED-RED200圖2鍵盤控制循環(huán)燈(二)數(shù)碼管顯示模塊:

R10R4R3R5R6R7R8R910k10k10k10k10k10k10k10kC21930pFU1XTAL1X1CRYSTALC118XTAL29RSTP0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD393837363534333221222324252627281011121314151617R11kC31uF29303130pF12345678PSENALEEAR251kP1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7AT89C51圖31位靜態(tài)數(shù)碼管顯示

VCCVCCC21930pFR10R4R3R5R6R7R8R9R14R13R12R11R15R16R18R17R22R21R20R19R23R24R26R25R34R33R32R27R28R29R30R31U1XTAL110k10k10k10k10k10k10k10kP0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD39383736353433322122232425262728101112131415161710k10k10k10k10k10k10k10k10k10k10k10k10k10k10k10k10k10k10k10k10k10k10k10kX1CRYSTAL18XTAL29RSTR11kC31uF293031PSENALEEAR251k12345678P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7AT89C51圖44位靜態(tài)數(shù)碼管顯示P0.0P0.1P0.2P0.3P0.4P0.5P0.6P0.7P2.3P2.2P2.1P2.0VCCC1U130PF191P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD393837363534333221222324252627281011121314151617P0.0P0.1P0.2P0.3P0.4P0.5P0.6P0.7P2.0P2.1P2.2P2.3P2.4P2.5P2.6P2.7RXDTXDINT0INT1T0T1WRRDP0.0P0.1P0.2P0.3P0.4P0.5P0.6P0.723456789XTAL1RP1X1CRYSTAL18C230PFXTAL2C3910uRSTVCCRESPACK-8R110kVCC293031PSENALEEAP1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.712345678P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7AT89C51圖54位動(dòng)態(tài)數(shù)碼管顯示VCCRP1U119XTAL1P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD393837363534333221222324252627281011121314151617D0D1D2D3D4D5D6D7123456789RESPACK-8D0D1D2D3D4D5D6D7WE1WE2WE3WE4WE5WE6abcdefghU223456789D0D1D2D3D4D5D6D7LEOE74HC573Q0Q1Q2Q3Q4Q5Q6Q71918171615141312abcdefgh18XTAL2DULA1119RSTU3D0D1D2D3D4D5D6D723456789D0D1D2D3D4D5D6D7LEOE74HC573WRQ0Q1Q2Q3Q4Q5Q6Q71918171615141312WE1WE2WE3WE4WE5WE6293031PSENALEEADULAWELA12345678P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.780C51T0T0T1WRRDT1WELA111RD圖6獨(dú)立鍵盤加減清零數(shù)碼管顯示U274LS164U374LS16413121110131211101312111013121110654365436543654U41DSRG81D74LS1643U574L1DSRG81DSRG8C1/->C1/->C1/->RRRC1/->8&&&&21821821899921RXDC1U130PF19XTAL1P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD393837363534333221222324252627281011121314151617P0.0P0.1P0.2P0.3P0.4P0.5P0.6P0.7P2.0P2.1P2.2P2.3P2.4P2.5P2.6P2.7RXDTXDINT0INT1T0T1WRRDTXDVCCRP11P0.0P0.1P0.2P0.3P0.4P0.5P0.6P0.723456789RESPACK-8X1CRYSTALC230PF18XTAL2C39RSTVCCR110k10uVCC293031PSENALEEAP1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.712345678P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.780C519RVCCSRG8圖74位74LS驅(qū)動(dòng)靜態(tài)數(shù)碼管顯示

161514131211109161514131211109161514131211109RN110kRN210kRN310k161514131211109RN410k123456781234567812345678976543211597654321159765432115Q7Q7Q6Q5Q4Q3Q2Q1Q0Q7Q7Q6Q5Q4Q3Q2Q1Q0Q7Q7Q6Q5Q4Q3Q2Q1Q074HC59574HC59574HC595Q7Q7Q6Q5Q4Q3Q2Q1Q0131012U2U3U4976543211512345678U574HC595DSSH_CPDSSH_CPDSSH_CP131012141113101214111310121411P1.0RXDTXDC130pFX1CRYSTALU119XTAL1P0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD39P0.038P0.137P0.236P0.335P0.434P0.533P0.632P0.721222324252627281011121314151617P2.0P2.1P2.2P2.3P2.4P2.5P2.6P2.7RXDTXDINT0INT1T0T1WRRDC2C330pF10u18XTAL2RP11P0.02P0.13P0.24P0.35P0.46P0.57P0.68P0.79RESPACK-89RSTR110k293031PSENALEEAP1.01P1.12P1.23P1.34P1.45P1.56P1.67P1.78P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7AT89C511411DSSH_CPST_CPST_CPST_CPST_CPOEMROEMROEMROEMR圖84位74HC595靜態(tài)顯示(三)鍵盤顯示模塊:

C1191nFCRYSTALU1XTAL1X1C2GNDVCC18XTAL21nFC39100uR110kVCCRSTP0.0/AD0P0.1/AD1P0.2/AD2P0.3/AD3P0.4/AD4P0.5/AD5P0.6/AD6P0.7/AD7P2.0/A8P2.1/A9P2.2/A10P2.3/A11P2.4/A12P2.5/A13P2.6/A14P2.7/A15P3.0/RXDP3.1/TXDP3.2/INT0P3.3/INT1P3.4/T0P3.5/T1P3.6/WRP3.7/RD393837363534333221222324252627281011121314151617P0.0P0.1P0.2P0.3P0.4P0.5P0.6P0.7P2.0P2.1P2.2P2.3P2.4P2.5P2.6P2.7RXDTXDINT0INT1T0T1WRRDGND293031PSENALEEAVCCP1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.712345678P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7AT89C51R3R4R5R6R7R8R9R1010k10k10k10k10k10k10k10kP0.0P0.1P0.2P0.3P0.4P0.5P0.6P0.7P1.0VCCRP11P1.1P0.02P0.13P0.24P0.35P0.46P0.57P0.68P0.79RESPACK-8P1.2P1.3P1.7P1.6P1.5P1.4圖90到F矩陣鍵盤

四、軟件程序流程圖

流水燈循環(huán)左移右移程序框圖:開始運(yùn)行主程序給P1口賦初值80HA循環(huán)左移,并在P1口輸出否調(diào)用延時(shí)程序判別A與80H是否相等是A循環(huán)右移,并在P1口輸出否調(diào)用延時(shí)程序判別A與01H是否相等結(jié)束

是1、

、0到F一位靜態(tài)顯示程序框圖:開始1.建0F的字形碼表2.用累加器A控制P0口并傳遞參數(shù)3.R0記錄目前顯示的字型碼R0=0A=R0查字型碼表,顯示0延時(shí)INCR0是R0=16?否繼續(xù)查表,顯示下一個(gè)字型延時(shí)

3、0到9一位靜態(tài)顯示程序框圖:

開始(P0)=0A=P0查字型碼表,取得段驅(qū)動(dòng)碼段驅(qū)動(dòng)碼送P0口延時(shí)(R0)+1NR0=10?YR0=02

4、動(dòng)態(tài)數(shù)碼顯示程序框圖:

開始P0口,P2口初始化置相應(yīng)的使能位查表顯示延時(shí)N顯示完Y置使能位處值返回

5、4×4矩陣矩陣鍵盤數(shù)碼顯示程序框圖:主程序圖:

開始掃描N是否有鍵按下YY識(shí)別是哪一個(gè)鍵按下通過(guò)P0口查詢顯示該序號(hào)

判別是否有鍵按下程序:

開始P1=FFH,P1.2=0P1=FFH,P1.0=0有鍵按下嗎?有鍵按下嗎?延時(shí)去抖動(dòng)延時(shí)10ms真的有鍵按下?真的有鍵按下?根據(jù)當(dāng)前狀態(tài)識(shí)別按鍵根據(jù)當(dāng)前狀態(tài)識(shí)別按鍵P1=FFH,P1.1=0P1=FFH,P1.3=0有鍵按下嗎?有鍵按下嗎?延時(shí)10ms延時(shí)10ms真的有鍵按下嗎?真的有鍵按下嗎?根據(jù)當(dāng)前狀態(tài)識(shí)別按鍵根據(jù)當(dāng)前狀態(tài)識(shí)別按鍵

五、實(shí)習(xí)的心得體會(huì)

本次單片機(jī)實(shí)習(xí)我們一共完成了三個(gè)模塊的程序設(shè)計(jì),包括:led顯示模塊、數(shù)碼管顯示模塊和鍵盤模塊。分別實(shí)現(xiàn)了流水燈的循環(huán)點(diǎn)亮控制、數(shù)碼管的靜態(tài)和動(dòng)態(tài)計(jì)數(shù)顯示,還有矩陣鍵盤按鍵控制數(shù)碼管顯示的程序設(shè)計(jì)。然后我們分別用protues系統(tǒng)仿真軟件對(duì)各個(gè)模塊進(jìn)行了模擬仿真,用keil軟件編制了匯編語(yǔ)言程序,驗(yàn)證了我們所設(shè)計(jì)的程序。

這次實(shí)習(xí)還使我理解了編寫程序的一些技巧。單片機(jī)應(yīng)用系統(tǒng)一般由包含多個(gè)模塊的主程序和由各種子程序組成。每一模塊都要完成一個(gè)明確的任務(wù),實(shí)現(xiàn)某個(gè)具體的功能,如計(jì)算、接受、發(fā)送、延時(shí)、顯示等。采用模塊化程序設(shè)計(jì)方法,就是將這些具體功能程序進(jìn)行獨(dú)立設(shè)計(jì)和分別調(diào)試,最后將這些模塊程序裝配成整體程序并進(jìn)行聯(lián)合調(diào)試。模塊化程序設(shè)計(jì)方法的優(yōu)點(diǎn):一個(gè)模塊可以為多個(gè)程序所共享;單個(gè)功能明確的程序模塊的設(shè)計(jì)和調(diào)試比較方便,容易完成;利用已經(jīng)編好的成熟模塊,將大大縮短開發(fā)程序的時(shí)間,降低開發(fā)成本。采用循環(huán)結(jié)構(gòu)和子程序結(jié)構(gòu)可以使程序的容量大大減少,提高程序的效率,節(jié)省內(nèi)存。對(duì)于多重循環(huán),要注意各重循環(huán)的初值和循環(huán)結(jié)束的條件,避免出現(xiàn)程序無(wú)休止循環(huán)的“死循環(huán)”現(xiàn)象;

通過(guò)這次的實(shí)習(xí)我發(fā)現(xiàn),只有理論水平提高了,才能夠?qū)⒄n本知識(shí)與實(shí)踐相結(jié)合,理論知識(shí)服務(wù)于教學(xué)實(shí)踐,以增強(qiáng)自己的動(dòng)手能力。這次實(shí)習(xí)十分有意義,這次實(shí)習(xí)我們知道了理論和實(shí)踐的距離,也知道了理論和實(shí)踐相結(jié)合的重要性。

回顧起此次課程設(shè)計(jì),感覺(jué)受益匪淺,從拿到題目到完成整個(gè)編程,從理論到實(shí)踐,學(xué)到很多很多的課堂理論中沒(méi)學(xué)到過(guò)的東西,不僅對(duì)鍵盤的識(shí)別技術(shù)這一章節(jié)的知識(shí)點(diǎn)有了深刻的認(rèn)識(shí),而且對(duì)這學(xué)期開設(shè)的單片機(jī)這門課程有了更全面的了解,尤其是在學(xué)習(xí)使用proteus軟件片編程和仿真時(shí)收獲良多。通過(guò)這次單片機(jī)課程設(shè)計(jì),還使我懂得了實(shí)踐的重要性。同時(shí)在程序調(diào)試的過(guò)程中提高自己的發(fā)現(xiàn)問(wèn)題、解決問(wèn)題、實(shí)際動(dòng)手和獨(dú)立思考的能力。

這次課程設(shè)計(jì)能順利的完成,除了我們的努力外,當(dāng)然也離不開指導(dǎo)老師申老師的辛勤指導(dǎo),致使我在設(shè)計(jì)的過(guò)程中學(xué)到了很多實(shí)用性的知識(shí)。同時(shí),對(duì)給過(guò)我?guī)椭乃型瑢W(xué)和各位指導(dǎo)老師表示忠心的感謝!

附錄:程序清單

P1口閃亮:

ORG0000HLOOP:MOVP1,#01HACALLDELAYMOVP1,#00HACALLDELAYSJMPLOOPDELAY:MOVR7,#250DEL1:MOVR6,#250DJNZR6,$DJNZR7,DEL1RETEND

流水燈循環(huán)左移右移:方法一:

ORG0000HMOVA,#01HLOOP:MOVP1,AMOVR5,#10LOOP1:ACALLDELAYDJNZR5,LOOP1RLA

JBACC.7,LOOP2SJMPLOOPLOOP2:MOVP1,AMOVR5,#10LOOP3:ACALLDELAYDJNZR5,LOOP3RRA

JBACC.0,LOOPSJMPLOOP2DELAY:MOVR7,#250DEL1:MOVR6,#250DJNZR6,$DJNZR7,DEL1RETEND方法二:

ORG0000HMOVA,#80HLOOP:RLA

MOVP1,AACALLDELAY

CJNEA,#80H,LOOP

LOOP1:RRAMOVP1,AACALLDELAY

CJNEA,#01H,LOOP1SJMPLOOP

DELAY:MOVR7,#0FFHDELAY1:MOVR6,#0FFHDELAY2:MOVR5,#03HDELAY3:DJNZR5,DELAY3DJNZR6,DELAY2DJNZR7,DELAY1RETEND方法三:

ORG0000HMOVA,#80HMOVR0,#08HLOOP:RLAMOVP1,AACALLDELAY

DJNZR0,LOOPMOVR0,#07HLOOP1:RRAMOVP1,AACALLDELAYDJNZR0,LOOP1MOVR0,#07HSJMPLOOP

DELAY:MOVR7,#0FFHDELAY1:MOVR6,#0FFHDELAY2:MOVR5,#03HDELAY3:DJNZR5,DELAY3DJNZR6,DELAY2DJNZR7,DELAY1RETEND方法四:

ORG0000HMOVA,#00HSETBCYLOOP:RLCAJCLOOP1MOVP1,A

ACALLDELAY

SJMPLOOPLOOP1:RRCAJCLOOPMOVP1,AACALLDELAYSJMPLOOP1DELAY:MOVR7,#0FFHDELAY1:MOVR6,#0FFHDELAY2:MOVR5,#03HDELAY3:DJNZR5,DELAY3DJNZR6,DELAY2DJNZR7,DELAY1RETEND

從中間向兩邊,再?gòu)膬蛇呄蛑虚g循環(huán)點(diǎn)亮:

ORG0000HSTAR:MOVR0,#00HMOVR1,#07MOVA,R0

MOVDPTR,#TABLOOP:MOVCA,@A+DPTRMOVP1,AMOVR5,#10LOOP1:ACALLDELDJNZR5,LOOP1INCR0MOVA,R0DJNZR1,LOOPSJMPSTARDEL:MOVR7,#200DEL1:MOVR6,#250DJNZR6,$DJNZR7,DEL1RETTAB:DB

18H,24H,42H,81H,42H,24H,18HEND

鍵盤控制流水燈循環(huán)點(diǎn)亮:

按鍵P1.5P1.6控制循環(huán)燈移動(dòng)方向ORG0000HAJMPMAINORG0003HAJMPETORG0030HMAIN:MOVSP,#60HSETBEASETBIT0SETBEX0CLRC

MOVA,#0FFHMOVP2,ALCALLDEL

LOOP:JNB21H.1,L;檢測(cè)標(biāo)志RRCA;右移動(dòng)MOVP2,AAJMPDEE

L:RLCA;左移動(dòng)MOVP2,ADEE:LCALLDELAJMPLOOPET:CLREAPUSHACCPUSHPSWLCALLDELAYMOVA,#0FFHMOVP1,ANOPNOP

MOVA,P1;讀鍵值A(chǔ)NLA,#0F0H

CJNEA,#0F0H,NEXT1AJMPNEXT

NEXT1:JBACC.5,NEXT2

CLR21H.1;按鍵后產(chǎn)生標(biāo)志AJMPNEXT

NEXT2:JBACC.6,NEXT

SETB21H.1;按鍵后產(chǎn)生標(biāo)志NEXT:SETBEAPOPPSWPOPACCHHH:RETI

DEL:MOVR6,#250DEL11:MOVR5,#250DJNZR5,$DJNZR6,DEL11RET

DELAY:MOVR6,#10DEL1:MOVR5,#200DEL2:DJNZR5,$DJNZR6,DEL1RETEND花樣流水燈:

ORG0000HSTART:MOVR0,#00HMOVP1,#00HLOOP:MOVA,R0ADDA,#0CHMOVCA,@A+PCCJNEA,#01H,XSHSJMPSTARTXSH:MOVP1,AACALLDELAYINCR0SJMPLOOP

DB0FFH,00H,0FFH,00H,0FFH,00H,0FFH,00H,0FH,0F0H,0FH,0F0H,0FH,0F0H,0FH

DB0F0H,0FH,0F0H,0AAH,55H,0AAH,55H,0AAH,55H,0AAH,55H,0AAH,55H,81H,42H

DB24H,18H,24H,42H,81H,42H,24H,18H,24H,42H,81H,42H,24H,18H,24H,42H,81H

DB42H,24H,18H,24H,42H,81H,03H,06H,0CH,18H,30H,60H,0C0H,60H,30H,18H,0CH

DB06H,03H,06H,0CH,18H,30H,60H,0C0H,60H,30H,18H,0CH,06H,03H,01HDELAY:MOVR7,#0FFHDELAY1:MOVR6,#0FFHDELAY2:MOVR5,#03HDELAY3:DJNZR5,DELAY3DJNZR6,DELAY2DJNZR7,DELAY1RETEND

1位靜態(tài)數(shù)碼顯示:ORG0000HMOVR0,#0FFHDISPLY:INCR0

CJNER0,#0AH,DISPLY1MOVR0,#0FFHSJMPDISPLYDISPLY1:MOVA,R0ADDA,#06HMOVCA,@A+PCMOVP0,AACALLDELAYSJMPDISPLY

DTAB:DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H

DB88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,89H,7FH,0BFHDELAY:MOVR7,#0FFHDELAY1:MOVR6,#0FFHDELAY2:MOVR5,#03HDELAY3:DJNZR5,DELAY3DJNZR6,DELAY2DJNZR7,DELAY1RET

2位靜態(tài)數(shù)碼顯示:ORG0000HMOVR0,#0FFHMOVR1,#00HDISPLY:INCR0

CJNER0,#0AH,DISPLY1INCR1

CJNER1,#0AH,DISPLY2MOVR0,#0FFHMOVR1,#00HMOVP0,#0FFHAJMPDISPLYDISPLY2:MOVA,R1ADDA,#10HMOVCA,@A+PCMOVP0,AMOVR0,#0FFHAJMPDISPLYDISPLY1:MOVA,R0ADDA,#06HMOVCA,@A+PCMOVP2,AACALLDELAYAJMPDISPLYDTAB:DB

0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H

DB88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,89H,7FH,0BFHDELAY:MOVR7,#0FFHDELAY1:MOVR6,#0FFHDELAY2:MOVR5,#03HDELAY3:DJNZR5,DELAY3DJNZR6,DELAY2DJNZR7,DELAY1RETEND

3位靜態(tài)數(shù)碼顯示:ORG0000HSTART:MOVR0,#0FFHMOVR1,#00HMOVR2,#00HMOVP3,#0FFHMOVP2,#0FFHMOVP0,#0FFHDISPLY:INCR0

CJNER0,#0AH,DISPLY1MOVR0,#0FFHINCR1

CJNER1,#0AH,DISPLY2MOVR1,#00HMOVP2,#0C0HINCR2

CJNER2,#0AH,DISPLY3SJMPSTARTDISPLY3:MOVA,R2ADDA,#16HMOVCA,@A+PCMOVP0,ASJMPDISPLYDISPLY2:MOVA,R1ADDA,#0EHMOVCA,@A+PCMOVP2,A

SJMPDISPLYDISPLY1:MOVA,R0ADDA,#06HMOVCA,@A+PCMOVP3,AACALLDELAYSJMPDISPLY

DTAB:DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H

DB88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,89H,7FH,0BFHDELAY:MOVR7,#0FFHDELAY1:MOVR6,#0FFHDELAY2:MOVR5,#03HDELAY3:DJNZR5,DELAY3DJNZR6,DELAY2DJNZR7,DELAY1RETEND

4位靜態(tài)數(shù)碼顯示:ORG0000HSTART:MOVR0,#0FFHMOVR1,#00HMOVR2,#00HMOVR3,#00HMOVP1,#0FFHMOVP3,#0FFHMOVP2,#0FFHMOVP0,#0FFHDISPLY:INCR0

CJNER0,#0AH,DISPLY1MOVR0,#0FFHINCR1

CJNER1,#0AH,DISPLY2MOVR1,#00HMOVP3,#0C0HINCR2

CJNER2,#0AH,DISPLY3MOVR2,#00HMOVP2,#0C0HINCR3

CJNER3,#0AH,DISPLY4SJMPSTARTDISPLY4:MOVA,R3ADDA,#1EHMOVCA,@A+PCMOVP0,ASJMPDISPLYDISPLY3:MOVA,R2ADDA,#16HMOVCA,@A+PCMOVP2,ASJMPDISPLYDISPLY2:MOVA,R1ADDA,#0EHMOVCA,@A+PCMOVP3,A

SJMPDISPLYDISPLY1:MOVA,R0ADDA,#06HMOVCA,@A+PCMOVP1,AACALLDELAYSJMPDISPLY

DTAB:DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H

DB88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,89H,7FH,0BFHDELAY:MOVR7,#0AHDELAY1:MOVR6,#0FFHDELAY2:MOVR5,#03HDELAY3:DJNZR5,DELAY3DJNZR6,DELAY2DJNZR7,DELAY1RETEND

74HC595四位穩(wěn)定顯示:1)最大數(shù)為9999的計(jì)數(shù)器ORG0000HAJMPMAINORG000BHAJMPCRT0ORG0020HMAIN:MOVR1,#33HMOVR2,#04HCLEAR:MOV@R1,#33HDECR1

DJNZR2,CLEARMOVSP,#60HMOVTMOD,#01HMOVTH0,#3CH

MOVTL0,#0B0HSETBEA

SETBET0SETBTR0

MOVR7,#1

MOVDPTR,#DTABLOOP:MOVR1,#33HMOVR2,#04HMOVR3,#08HMOVR4,#01HLOOP1:MOVA,R3MOVP2,ARRA

MOVR3,AMOVA,@R1

CJNER4,#00H,MODEXSH:LCALLDISLCALLDEL

DECR1

DJNZR2,LOOP1

AJMPLOOP

MODE:CJNEA,#00H,FHMOVR4,#01HMOVA,#0AHSJMPXSHFH:MOVR4,#00HSJMPXSHCRT0:DJNZR7,RRRMOVR7,#1INC30HMOVR0,30H

CJNER0,#0AH,RRRMOV30H,#00HINC31HMOVR0,31H

CJNER0,#0AH,RRRMOV31H,#00HINC32HMOVR0,32H

CJNER0,#0AH,RRRMOV32H,#00HINC33HMOVR0,33H

CJNER0,#0AH,RRRMOV33H,#00HRRR:MOVTH0,#3CHMOVTL0,#0B0HRETI

DIS:MOVCA,@A+DPTRMOVP0,ARET

DEL:MOVR6,#20DEL1:MOVR5,#150DEL2:DJNZR5,$DJNZR6,DEL1RETDTAB:DB

0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFHDB

88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,89H,7FH,0BFHEND

2)最高位為零時(shí),最高位不顯示ORG0000HAJMPMAINORG000BHAJMPCRT0ORG0020HMAIN:MOVR1,#33HMOVR2,#04HCLEAR:MOV@R1,#00HDECR1

DJNZR2,CLEARMOVSP,#60HMOVTMOD,#01HMOVTH0,#3CHMOVTL0,#0B0HSETBEASETBET0SETBTR0MOVR7,#1

MOVDPTR,#DTABLOOP:MOVR1,#33HMOVR2,#04HMOVR3,#08HLOOP1:MOVA,R3MOVP2,ARRAMOVR3,AMOVA,@R1LCALLDISLCALLDELDECR1

DJNZR2,LOOP1AJMPLOOPCRT0:DJNZR7,RRRMOVR7,#1MOVR0,#30HMOVR4,04HCON:INC@R0

CJNE@R0,#0AH,RRRMOV@R0,#00HINCR0

DJNZR4,CONRRR:MOVTH0,#3CHMOVTL0,#0B0HRETI

DIS:MOVCA,@A+DPTRMOVP0,ARET

DEL:MOVR6,#20DEL1:MOVR5,#150DEL2:DJNZR5,$DJNZR6,DEL1RET

DTAB:DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFH

DB88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,89H,7FH,0BFHEND

3)最大數(shù)為256的計(jì)數(shù)器DATDATA30HBWDATA31HSHWDATA32HGWDATA33HORG0000HAJMPMAINORG000BHAJMPCOUNTORG0030HMAIN:MOVSP,#60HMOVTMOD,#01HMOVTH0,#3CHMOVTL0,#0B0HSETBEASETBET0SETBTR0MOVR7,#2MOVDAT,#00HLOOP:LCALLCHANGEMOVP2,#01HMOVA,GWLCALLDISLCALLDELMOVP2,#02HMOVA,SHWLCALLDISLCALLDELMOVP2,#04HMOVA,BWLCALLDISLCALLDELMOVP2,#08HMOVA,#0AHLCALLDISLCALLDELAJMPLOOPCOUNT:DJNZR7,RRRMOVR7,#2INCDAT

RRR:MOVTH0,#3CHMOVTL0,#0B0HRETI

CHANGE:MOVA,DATMOVB,#100DIVABMOVBW,AMOVA,#10XCHA,BDIVABMOVSHW,AMOVGW,BRET

DIS:MOVDPTR,#TABMOVCA,@A+DPTRMOVP0,ARET

DEL:MOVR6,#20DEL1:MOVR5,#150DEL2:DJNZR5,$DJNZR6,DEL1RET

TAB:DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFHEND

74LS4位靜態(tài)數(shù)碼顯示:方法一:ORG0000HMOVR3,#04HMOVR0,#20HSTART:LCALLDISPLAYLCALLCOUNTLCALLDELAYSJMPSTARTCOUNT:INC@R0

CJNE@R0,#0AH,DONMOV@R0,#00HSHW:INCR0INC@R0

CJNE@R0,#0AH,DE1

MOV@R0,#00HBW:INCR0INC@R0

CJNE@R0,#0AH,DE2MOV@R0,#00HQW:INCR0INC@R0

CJNE@R0,#0AH,DE3MOV@R0,#00HDE3:DECR0DE2:DECR0DE1:DECR0DON:RET

DISPLAY:MOVSCON,#00HLOOP:MOVA,@R0ADDA,#0FHMOVCA,@A+PCMOVSBUF,AJNBTI,$CLRTIINCRDJNZR3,LOOPMOVR3,#04HMOVR0,#20HDON1:RET

DTAB:DB3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH

DB77H,7CH,39H,5EH,79H,71H,00H,0F3H,76H,80H,40HDELAY:MOVR7,#50DELAY1:MOVR6,#100DELAY2:MOVR5,#20DJNZR5,$DJNZR6,DELAY2DJNZR7,DELAY1RETEND

方法二:ORG0000HAJMPMAINORG000BHAJMPCOUNTORG0020HMAIN:MOVR1,#30HMOVR2,#04HCLEAR:MOV@R1,#00HINCR1

DJNZR2,CLEARMOVSP,#60HMOVTMOD,#01HMOVTH0,#0B0HSETBEASETBET0SETBTR0MOVR3,#3

MOVDPTR,#DTABMOVSCON,#00HDISPLY:MOVR1,#30HMOVR2,#04HLOOP:MOVA,@R1

MOVCA,@A+DPTRMOVSBUF,AJNBTI,$CLRTIINCR1

DJNZR2,LOOPACALLDELSJMPLOOPCOUNT:DJNZR3,RRRMOVR3,#3MOVR0,#30HMOVR4,#04HCON:INC@R0

CJNE@R0,#0AH,RRRMOV@R0,#00HINCR0

DJNZR4,CONRRR:MOVTH0,#3CHMOVTL0,#0B0HRETI

DEL:MOVR6,#250DEL1:MOVR5,#250DEL2:DJNZR5,$DJNZR6,DEL1RET

DTAB:DB3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH

DB77H,7CH,39H,5EH,79H,71H,00H,0F3H,76H,80H,40HEND

動(dòng)態(tài)數(shù)碼顯示:

ORG0000HACALLSTART

START1:MOV@R0,#00HINCR0

DJNZR2,START1ACALLSTART2

COUNT:CJNE@R0,#0AH,ACALLDISMOV@R0,#00HINCR0INC@R0

CJNER0,#34H,COUNTACALLSTARTAJMPSTART1ACALLDIS:ACALLDISPLAYINC@R0AJMPCOUNTDISPLAY:ACALLSTARTMOVR4,#01HDISPLAY1:MOVA,@RMOVDPTR,#DTABMOVCA,@A+DPTRMOVP0,AINCR0MOVA,R3MOVP2,ARLA

MOVR3,AACALLDELAY

DJNZR2,DISPLAY1ACALLSTART

DJNZR4,DISPLAY1RETDTAB:DB

3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH

DB77H,7CH,39H,5EH,79H,71H,00H,0F3H,76H,80H,40HSTART:MOVR3,#0FEHSTART2:MOVR0,#34HMOVR2,#04HRET

DELAY:MOVR7,#088HDEL1:MOVR6,#88HDEL2:MOVR5,#01HDEL3:DJNZR5,DEL3DJNZR6,DEL2DJNZR7,DEL1RETEND

獨(dú)立鍵盤加減清零數(shù)碼顯示:#include

#defineucharunsignedchar#defineuintunsignedintsbitkey1=P3^4;sbitkey2=P3^5;sbitkey3=P3^6;sbitkey4=P3^7;sbitdula=P2^6;sbitwela=P2^7;ucharcodetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};voiddelayms(uint);ucharnumt0,num;voiddisplay(numdis){ucharshi,ge;shi=numdis/10;ge=numdis%10;wela=1;P0=0xfe;wela=0;dula=1;

P0=table[shi];dula=0;P0=0xff;delayms(5);wela=1;P0=0xfd;wela=0;dula=1;

P0=table[ge];dula=0;P0=0xff;

delayms(5);}

voiddelayms(uintx){uinti,j;

for(i=x;i>0;i--)

for(j=110;j>0;j--);}voidinit(){TMOD=0x01;

TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;}

voidkeyscan(){if(key1==0){delayms(10);if(key1==0){num++;

if(num==60)num=0;

while(!key1);}}if(key2==0){delayms(10);if(key2==0){if(num==0)num=60;num--;

while(!key2);}}if(key3==0){delayms(10);if(key3==0){num=0;

while(!key2);}}if(key4==0){delayms(10);if(key4==0)

{while(!key4);TR0=~TR0;}}}voidmain(){init();while(1){keyscan();

display(num);}}

voidT0_time()interrupt1{TH0=(65536-50000)/256;TL0=(65536-50000)%256;numt0++;

if(numt0==20){numt0=0;num++;

if(num==60)num=0;}}

矩陣鍵盤0到F顯示:KEY_DATADATA30HORG0000H

MOVKEY_DATA,#10HAJMPMAINORG0030HMAIN:MOVSP,#60HLOOP:LCALLSCANMOVA,KEY_DATAMOVDPTR,#TABMOVCA,@A+DPTRMOVP0,ALCALLDELAJMPLOOP

SCAN:MOVA,#0FHMOVP1,AMOVA,P1

CJNEA,#0FH,KEYSCANRET

KEYSCAN:LCALLDELMOVR2,#7FHMOVR3,#4MOVR0,#00HKEYSM1:MOVA,R2MOVP1,ARRAMOVR2,AMOVA,P1ANLA,#0FH

CJNEA,#0FH,JSADDINCR0

DJNZR3,KEYSM1RET

JSADD:JBACC.0,JSADD1MOVA,#0AJMPJSADD4

JSADD1:JBACC.1,JSADD2MOVA,#4AJMPJSADD4

JSADD2:JBACC.2,JSADD3MOVA,#8AJMPJSADD4

JSADD3:JBACC.3,JSADD4MOVA,#12JSADD4:ADDA,R0

MOVKEY_DATA,ADEL:MOVR6,#50DEL1:MOVR5,#200DJNZR5,$DJNZR6,DEL1RET

TAB:DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H

DB88H,83H,0C6H,0A1H,86H,8EH,0FFH,0CH,89H,7FH,0BFHEND

友情提示:本文中關(guān)于《單片機(jī)實(shí)訓(xùn)總結(jié)》給出的范例僅供您參考拓展思維使用,單片機(jī)實(shí)訓(xùn)總結(jié):該篇文章建議您自主創(chuàng)作。

來(lái)源:網(wǎng)絡(luò)整理 免責(zé)聲明:本文僅限學(xué)習(xí)分享,如產(chǎn)生版權(quán)問(wèn)題,請(qǐng)聯(lián)系我們及時(shí)刪除。


單片機(jī)實(shí)訓(xùn)總結(jié)》由互聯(lián)網(wǎng)用戶整理提供,轉(zhuǎn)載分享請(qǐng)保留原作者信息,謝謝!
鏈接地址:http://www.seogis.com/gongwen/522669.html