📄 lcd_driver.vhd
字号:
state<=15; counter<=0; end if; ------------------Initialization Complete------------------------ ---------------WRITE DATA HAVE ----------------- if( Write_TO_LCD='1') then Rs<='1'; RW<='0'; if(substate=0 and counter=600) then -- wait for Data valid DATA<=nhdata_Int; counter<=0; substate<=1; elsif(substate=1 and counter=2) then EN<='1'; counter<=0; substate<=2; elsif(substate=2 and counter=12) then EN<='0'; substate<=3; counter<=0; elsif(substate=3 and counter=100) then ---delay for two nible DATA<=nldata_Int;-- IT HAS BEEN FIXED counter<=0; substate<=4; elsif(substate=4 and counter=2) then EN<='1'; counter<=0; substate<=5; elsif(substate=5 and counter=12) then EN<='0'; substate<=6; counter<=0; --WAIT FOR 2,000 counter elsif(substate=6 and counter=5000) then substate<=0; --LED2_Int <=NOT(LED2_Int); Cursor<=Cursor+1; Write_TO_LCD<='0'; counter<=0; end if; end if; ------------------ for instruction------------------ if(instruct_to_lcd='1')then RS<='0'; RW<='0'; if(substate=0 and counter=600) then DATA<=nhdata_Int; counter<=0; substate<=1; elsif(substate=1 and counter=2) then EN<='1'; counter<=0; substate<=2; elsif(substate=2 and counter=12) then EN<='0'; substate<=3; counter<=0; elsif(substate=3 and counter=100) then DATA<=nldata_Int; counter<=0; substate<=4; elsif(substate=4 and counter=2) then EN<='1'; counter<=0; substate<=5; elsif(substate=5 and counter=12) then EN<='0'; substate<=6; counter<=0; --WAIT FOR 640000 counter for instruction 1.6 ms elsif(substate=6 and counter=64000) then -- LED2_Int <=NOT(LED2_Int); substate<=0; Cursor<=Cursor+1; counter<=0; end if; end if; ----write speed and Range----------- if((LCD_Init_done='1'))then-- Write_TO_LCD <='0'; --instruct_to_lcd<='1'; if ( Cursor=0 and counter=100) then --;Clear Screen & Returns the Cursor Home instruct_to_lcd<='1'; nhdata_Int <= "0000";-- Clear LCD nldata_Int <= "0001";-- Clear LCD ------------------speed------------------------------------- elsif ( Cursor=1 ) then instruct_to_lcd<='0'; Write_TO_LCD <='1'; nhdata_Int <= "0101";--writ S nldata_Int <= "0011";--writ S -- RS<='1'; elsif(Cursor=2)then Write_TO_LCD <='1'; nhdata_Int <= "0111";--writ p nldata_Int <= "0000";--writ p --RS<='1'; elsif(Cursor=3)then Write_TO_LCD <='1'; nhdata_Int <= "0110";--writ e- nldata_Int <= "0101";--writ e- -- RS<='1'; elsif(Cursor=4)then Write_TO_LCD <='1'; nhdata_Int <= "0110";--writ e- nldata_Int <= "0101";--writ e- -- RS<='1'; elsif(Cursor=5)then Write_TO_LCD <='1'; nhdata_Int <= "0110";--writ d- nldata_Int <= "0100";--writ d- -- RS<='1'; elsif(Cursor=6)then Write_TO_LCD <='1'; nhdata_Int <= "0011";--writ :- nldata_Int <= "1010";--writ :- -- RS<='1'; elsif (Cursor=7)then Write_TO_LCD <='1'; nhdata_Int <= "1010";--writ space nldata_Int <= "0000";--writ space elsif(Cursor=8)then Write_TO_LCD <='1'; nhdata_Int <= Speed_digit1(7 downto 4);--writ digit 1 of speed nldata_Int <= Speed_digit1(3 downto 0);--writ digit 1 of speed -- RS<='1'; elsif(Cursor=9)then Write_TO_LCD <='1'; nhdata_Int <= speed_digit2(7 downto 4);--writ digit 2 of speed nldata_Int <= speed_digit2(3 downto 0);--writ digit 2 of speed -- RS<='1'; elsif(Cursor=10)then Write_TO_LCD <='1'; nhdata_Int <= "0010";--writ . nldata_Int <= "1110";--writ . -- RS<='1'; elsif(Cursor=11)then Write_TO_LCD <='1'; nhdata_Int <= speed_digit3(7 downto 4);--writ digit3 of speed nldata_Int <= speed_digit3(3 downto 0);--writ digit 3 of speed -- RS<='1'; elsif(Cursor=12)then Write_TO_LCD <='1'; nhdata_Int <= "1010";--writ space nldata_Int <= "0000";--writ space --RS<='0'; --- instraction elsif(Cursor=13)then Write_TO_LCD <='1'; --instruct_to_lcd<='0'; nhdata_Int <= "0110";--writ m nldata_Int <= "1101";--writ m --RS<='1'; -- befor EN low to high elsif(Cursor=14)then Write_TO_LCD <='1'; nhdata_Int <= "0010";--writ / nldata_Int <= "1111";--writ / -- RS<='1'; elsif(Cursor=15)then Write_TO_LCD <='1'; nhdata_Int <= "0111";--writ s nldata_Int <= "0011";--writ s-- RS<='1';-- -- ------------------------ move Cursor to next line----------- ---------------------- move Cursor to next line--------- command 11000000 elsif(Cursor=16)then --RS<='0'; --- instraction Write_TO_LCD <='0'; instruct_to_lcd<='1'; nhdata_Int <= "1100";--move Cursor to next line #XC0 nldata_Int <= "0000";--move Cursor to next line---- ------------------------range------------------------------------- elsif(Cursor=17)then --RS<='1'; Write_TO_LCD <='1'; instruct_to_lcd<='0'; nhdata_Int <= "0101";--write R nldata_Int <= "0010";--write R elsif(Cursor=18)then Write_TO_LCD <='1'; nhdata_Int <= "0110";--write a nldata_Int <= "0001";--write a -- RS<='1'; elsif(Cursor=19)then Write_TO_LCD <='1'; nhdata_Int <= "0110";--write n nldata_Int <= "1110";--write n -- RS<='1'; elsif(Cursor=20)then Write_TO_LCD <='1'; nhdata_Int <= "0110";--write g nldata_Int <= "0111";--write g -- RS<='1'; elsif (Cursor=21)then Write_TO_LCD <='1'; nhdata_Int <= "0110";--writ e- nldata_Int <= "0101";--writ e- elsif(Cursor=22)then Write_TO_LCD <='1'; nhdata_Int <= "0011";--write : nldata_Int <= "1010";--write : -- RS<='1'; elsif(Cursor=23)then Write_TO_LCD <='1'; nhdata_Int <= "1010";--writ space nldata_Int <= "0000";--writ space elsif(Cursor=24)then Write_TO_LCD <='1'; nhdata_Int <= Range_digit1(7 downto 4);--write digit 1 of Range nldata_Int <= Range_digit1(3 downto 0);--write digit 1 of Range -- RS<='1'; elsif(Cursor=25)then Write_TO_LCD <='1'; nhdata_Int <= Range_digit2(7 downto 4);--write digit 2 of Range nldata_Int <= Range_digit2(3 downto 0);--write digit 2 of Range -- RS<='1'; elsif(Cursor=26)then Write_TO_LCD <='1'; nhdata_Int <= "0010";--write . nldata_Int <= "1110";--write . -- RS<='1'; elsif(Cursor=27)then Write_TO_LCD <='1'; nhdata_Int <= Range_digit2(7 downto 4);--write digit 3 of Range nldata_Int <= Range_digit2(3 downto 0);--write digit 3 of Range -- RS<='1'; elsif(Cursor=28)then Write_TO_LCD <='1'; nhdata_Int <= "1010";--write space nldata_Int <= "0000";--write space -- RS<='1'; elsif(Cursor=29)then Write_TO_LCD <='1'; nhdata_Int <= "0110";--write m nldata_Int <= "1101";--write m --RS<='1'; -- befor EN low to high elsif(Cursor=30)then Write_TO_LCD <='1'; nhdata_Int <= "1010";--write space nldata_Int <= "0000";--write space elsif(Cursor=31)then Write_TO_LCD <='1'; nhdata_Int <= "1010";--write space nldata_Int <= "0000";--write space elsif((Cursor=32) and (exceed_Speed='1'))then instruct_to_lcd<='1'; Write_TO_LCD <='0'; nhdata_Int <= "0000"; ---care in this case Display on, Cursor off, Blink off nldata_Int <= "1111"; ---care in this case Display on, Cursor off, Blink off elsif((Cursor=32) and (exceed_Speed='0'))then Write_TO_LCD <='0'; LCD_Init_done <='0'; --wait for new data Write_complete <='1'; elsif((Cursor=33))then instruct_to_lcd<='0'; Write_TO_LCD <='0'; LCD_Init_done <='0'; --wait for new data Write_complete <='1'; ---- ----------------------end of data--------------------------------------- ------------------------range---------------------------------- end if; end if; New_Data_Previous <= New_Data; if ((New_Data='1')and(New_Data_Previous='0'))then LCD_Init_done <='1'; Cursor<=0; counter<=0; Write_complete <='0'; end if;end if;--rising_edgeend process; end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -