SPI74HC795計(jì)數(shù)器設(shè)計(jì)中心_第1頁
SPI74HC795計(jì)數(shù)器設(shè)計(jì)中心_第2頁
SPI74HC795計(jì)數(shù)器設(shè)計(jì)中心_第3頁
SPI74HC795計(jì)數(shù)器設(shè)計(jì)中心_第4頁
SPI74HC795計(jì)數(shù)器設(shè)計(jì)中心_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

SPI74HC795Counter 使用74hc595擴(kuò)展16個(gè)IO并且使用其中12個(gè)動(dòng)態(tài)驅(qū)動(dòng)4位7段數(shù)碼管顯示0—9999。Figure1:ExpandIOTable1:mainModuleFunctionSystemSystem74hc595Latch74hc595Serial74hc595Shift74hc595Table2:Dpy4ModuleFunctionSystemSystem74hc595Lach74hc595Serial74hc595Shift74hc59574hc595OutputLed74hc595OutputLed74hc595OutputLed74hc595OutputTable3:spiModuleFunctionSystemSystemMasterOutSerialMasterInSerialSpi1:StartSpi1bytehavebeenDirectionSet WriteDataReadDataFigureSpiFigure3:SpiTable4:ShiftModuleFunctionSystemSystemShiftClock:DatashiftformlowtohighaleachraisingLoaddatatoshiftregisterwhenWhenIsLoadhighdatawhilebeloadedintoshiftBitdatashiftedintoshift teachraisingedgeofEnableBitdatashiftedoutfromshift teachraisingedgeofshiftregisterFigure4:SpiStateModule outputoutput output[7:0] [7:0] output [1:0] 18 20 21 22 25wire26wire28 29wire31assign32assign33always@(posedgeClk)SckD1<=Sck; 35parameterBIT8=37always@(posedgeClk)//countshifted38if(SckEn&&SckUp)BitC<=BitC+1'b1;elseif(BitC==BIT8)BitC<=4'd0; 40assignMosi=DirSet?SftOut:1'b1;42always@(posedgeClk)//main43 s<=1'b0;IsDone<=1'b0;SckEn<=else0://IDLEbeginIsDone<=1'b0;IsDone<=1'b0;SckEn<=1'b0;if(IsSta)s<=1'b1; SckEn<=1'b1;if(BitC==BIT8)beginRdData<=DataOut;SckEn<=1'b0;IsDone<=1'b1;s<=57//spiclockgeneratoralways@(posedgeClk)//ShiftClockif(!Rst)beginSckC<=7'd0;Sck<=1'b0;SckState<=elsecase(SckStatebeginSckC<=7'd0;Sck<=1'd0;if(SckEn)SckState<=2;Sck<=1'b1;if(SckC>=TSET)beginSckState<=2;SckC<=7'd0;endelseSckC<=SckC+Sck<=if(SckC>=TSET) SckC<=7'd0;if(SckEn)SckState<=1;elseSckState<=0;elseSckC<=SckC+80wire81 82 SlClk=DirSet?SckNp:83assignIsSpiLd=84SHIFT8 97Figure5:7-SegmentLEDDisy(Dynamic25次每秒的時(shí)候,人1S有的七段數(shù)碼管能夠被顯示25次以上,這樣人眼就感覺所以數(shù)碼管是亮的。Table4:Codemapto08192A3B4C5D6E7FFigure6:SpiTransmitmoduleinputinputoutputoutputoutputoutput 13 zero= = = three= four= five= = seven= eight= nine= IDLEBYT0BYT1regregregregregregregregregregreg45wire47always@(posedge DirSet<=1'b0;IsSta<=1'b0;s<=1'b0;LchClk<=1'b0;SRst<=else0beginDirSet<=1;IsSta<=0;s<=3'd1;rdy<=0;SRst<=1; 1,2://nop2s<=s+ //WriteMSBBYTEOfbeginWrData<=dp;IsSta<=1;SRst<=1;s<=4; beginIsSta<=0;if(IsDone)begins<=5;LchClk<=0;end 5 //WriSBBYTEOfbeginWrData<=dat;IsSta<=1;s<=6; beginIsSta<=0;if(IsDone)begins<=0;LchClk<=1;rdy<=1;endalways@(posedgeif(rdy)beginDpy_n<=Dpy_n+if(Dpy_n>3)Dpy_n<=1'b0; always@(posedgeClkcase(Dpy_nbegindata<=Dpy0;dp<=begindata<=Dpy1;dp<=begindata<=Dpy2;dp<=begindata<=Dpy3;dp<=always@(posedgeClkcase(data0:dat<=1001:dat<=one;2:dat<=two;4:dat<=four;5:dat<=five;6:dat<=six;7:dat<=seven;8:dat<=eight;9:dat<=nine;spiModulemodule 9reg[3:0]10reg[3:0]11reg[3:0]14reg[6:0]15reg[9:0]16reg[13:0]19reg[22:0]20reg[3:0]i,j,23always@(posedgeClk if(!Rst) i<=4'd0;j<=4'd0;k<=4'd0; else if(C4> if(1000*(k+1)<=C4)k<=k+1'b1;elsebeginLed4<=k;C3<=(C4-1000*k);k<=4'd0; endelsebeg 3<=C4;Led4<=4'd0;end30if(C3> 100*(i+1)<=C3)i<=i+1'b1;elsebeginLed3<=i;C2<=(C3-100*i);i<=4'd0;32endelse 2<=C3;Led3<=4'd0; if(C2> 10*(j1)C2jj1'b1elsebeginLed2j;Led1<=C210*jj4'd0;endendelsebeginLed1<=C2;Led2<=4'd0;always@(posedgeif(!Rst) C5<=23'd0;C4<=else if(C5< )C5<=C5+ C5<=23'd0;if(C4<14'd9999)C4<=C4+1'b1;elseC4<= Dpy465這個(gè)例子的源碼位于文件夾SpiCoun

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論