LCD計(jì)數(shù)顯示程序復(fù)習(xí)過(guò)程_第1頁(yè)
LCD計(jì)數(shù)顯示程序復(fù)習(xí)過(guò)程_第2頁(yè)
LCD計(jì)數(shù)顯示程序復(fù)習(xí)過(guò)程_第3頁(yè)
LCD計(jì)數(shù)顯示程序復(fù)習(xí)過(guò)程_第4頁(yè)
LCD計(jì)數(shù)顯示程序復(fù)習(xí)過(guò)程_第5頁(yè)
已閱讀5頁(yè),還剩30頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、Good is good, but better carries it.精益求精,善益求善。LCD計(jì)數(shù)顯示程序-libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;-Uncommentthefollowinglibrarydeclarationifinstantiating-anyXilinxprimitivesinthiscode.-libraryUNISIM;-useUNISIM.VComponents.all;entitycounterisPor

2、t(clk:instd_logic;resetn:instd_logic;dout:outstd_logic_vector(7downto0);lcd_en:outstd_logic;lcd_rs:outstd_logic;lcd_rw:outstd_logic);endcounter;architectureBehavioralofcounteriscomponentcounter60isPort(clk:instd_logic;resetn:instd_logic;dout:outstd_logic_vector(7downto0);endcomponent;componentdecode

3、risPort(din:instd_logic_vector(3downto0);dout:outstd_logic_vector(8downto0);endcomponent;componentlcd_interfaceisport(clk:instd_logic;resetn:instd_logic;dout_s10:instd_logic_vector(8downto0);dout_s1:instd_logic_vector(8downto0);lcd_data:outstd_logic_vector(7downto0);lcd_en:outstd_logic;lcd_rs:outstd

4、_logic;lcd_rw:outstd_logic);endcomponent;signalddout_s10:std_logic_vector(8downto0);signalddout_s1:std_logic_vector(8downto0);signalddout:std_logic_vector(7downto0);beginu1:counter60portmap(clk,resetn,ddout);u2:decoderportmap(ddout(7downto4),ddout_s10);u3:decoderportmap(ddout(3downto0),ddout_s1);u4:

5、lcd_interfaceportmap(clk,resetn,ddout_s10,ddout_s1,dout,lcd_en,lcd_rs,lcd_rw);endBehavioral;-Company:-Engineer:-CreateDate:13:36:1003/30/06-DesignName:-ModuleName:count60-Behavioral-ProjectName:-TargetDevice:-Toolversions:-Description:-Dependencies:-Revision:-Revision0.01-FileCreated-AdditionalComme

6、nts:-libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;entitycounter60isPort(clk:instd_logic;resetn:instd_logic;dout:outstd_logic_vector(7downto0);endcounter60;architectureBehavioralofcounter60issignalcount:std_logic_vector(7downto0);signalcount_div:st

7、d_logic_vector(25downto0);begindout=count;process(clk)beginif(clkeventandclk=1)thenif(resetn=0)thencount_div0);elseif(count_div(25)=1)thencount_div0);elsecount_div=count_div+1;endif;endif;endif;endprocess;process(clk,resetn)beginifresetn=0thencount0);elsifrising_edge(clk)thenif(count_div(25)=1)theni

8、fcount(3downto0)=1001thencount(3downto0)=0000;count(7downto4)=count(7downto4)+1;elsecount(3downto0)=count(3downto0)+1;endif;ifcount=01011001thencountdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdout=100100000;endcase;endprocess;endBehavioral;libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.

9、all;useieee.std_logic_unsigned.all;entitylcd_interfaceisport(clk:instd_logic;resetn:instd_logic;dout_s10:instd_logic_vector(8downto0);dout_s1:instd_logic_vector(8downto0);lcd_data:outstd_logic_vector(7downto0);lcd_en:outstd_logic;lcd_rs:outstd_logic;lcd_rw:outstd_logic);endlcd_interface;architecture

10、lcd_interface_archoflcd_interfaceissignallcd_we_n:std_logic;signallcd_en_int:std_logic;signalw_comp_n:std_logic;signalseq_count:std_logic_vector(5downto0);signallcd_rs_data:std_logic_vector(8downto0);signaldelay_count:std_logic_vector(15downto0);signallcd_addr:std_logic_vector(5downto0);typestate_lc

11、d_write_typeis(lcd_write_idle,lcd_write_1,lcd_write_2,lcd_write_3,lcd_write_4);signalstate_lcd_write:state_lcd_write_type;typestate_typeis(idle,wait_1,wait_2,state_1,state_2,state_3,done);signalstate:state_type;begin-ThefollowingstatemachineinitializestheLCDandwritesthefollowingmessage-totheLCDpanel

12、-MemecDesign-MB1000Board-TheLCDinitializationsequenceconsistofwritingthe0 x38,0 x38,0 x06,0 x0e,-0 x01,0 x80,0 xc0sequenceofhexnumberstotheLCDcontrolregisters(please-refertotheLCDdatasheetforanexplanationoftheinitializationsequence).-AttheendoftheLCDinitializationsequence,theLCDisreadytobewritten-to

13、startingwithline1.Itshouldbenotedthatdelaysareinsertedbetween-2writestotheLCDpaneltomeettheLCDinitializationrequirements.Although,-theLCDpanelrequiresdifferentdelaysbetween2writes,afixdelayof20msis-insertedbetween2writestosimplytheinitializationdesign(the20msisthe-longestdelaythatisrequiredbytheLCDp

14、anel).A22-bitcounterisusedto-generatethisfixdelay.sequencer_state_register:process(clk,resetn)beginif(resetn=0)thenstateif(delay_count(15)=1)thenstate=wait_1;elsestateif(delay_count(15)=1)thenstate=state_1;elsestatestateif(w_comp_n=0)and(lcd_addr=000110)thenstate=wait_2;elsif(w_comp_n=0)thenstate=wa

15、it_1;elsestateif(delay_count(15)=1)thenstate=state_3;elsestateif(w_comp_n=0)and(lcd_addr=100111)thenstate=done;elsif(w_comp_n=0)thenstate=wait_2;elsestatestatelcd_we_nlcd_we_nlcd_we_nlcd_we_nlcd_we_nlcd_we_nlcd_we_n=1;endcase;endprocesssequencer_state_logic;-Thefollowingsectionsusesthelcd_we_nsignal

16、togeneratethelcd_ensignaland-awritecompletesignal(w_comp_n).Thew_comp_nsignalisusedtoresetvarious-countersthatareusedtogenerateLCDcontrolsignals.state_lcd_write_register:process(clk,resetn)beginif(resetn=0)thenstate_lcd_writeif(lcd_we_n=0)thenstate_lcd_write=lcd_write_1;elsestate_lcd_writeif(seq_cou

17、nt=000101)thenstate_lcd_write=lcd_write_2;elsestate_lcd_writeif(seq_count=011110)thenstate_lcd_write=lcd_write_3;elsestate_lcd_writeif(seq_count=110010)thenstate_lcd_write=lcd_write_4;elsestate_lcd_writestate_lcd_writelcd_en_int=0;w_comp_nlcd_en_int=0;w_comp_nlcd_en_int=1;w_comp_nlcd_en_int=0;w_comp

18、_nlcd_en_int=0;w_comp_nlcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_datalcd_rs_data=100100000;endcase;endprocess;-Thefollowingisa

19、22-bitfreerunningcounterthatisclearedwhenthereset-signalisassertedortheMSBofthecountergoesto1.Thiscounterisused-togeneratedelaysbetweenback-to-backwritestotheLCDcess(clk)beginif(clkeventandclk=1)thenif(resetn=0)thendelay_count0);elseif(delay_c

20、ount(15)=1)thendelay_count0);elsedelay_count=delay_count+1;endif;endif;endif;endprocess;-Thefollowingcounterisusedbythesequencertogeneratethelcd_ensignal.-ThecounterisresetattheendofeachwritetotheLCDwhenthew_comp_cess(clk)beginif(clkeventandclk=1)thenif(resetn=0)or(w_comp_n=0)thense

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(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)論