hobbyiclearner
Full Member level 2
Hi,
I wanted to know how I can flash the backlight of a 2 line character LCD module interfaced with FPGA while data is getting displayed. I am using VHDL (duration of flashing :2 secs on, 2 secs off).
A simple technique is to toggle with the display on off instructions in a seperate process by help of a loop (while counting till 2secs and then changing the value of databus after that for toggling the backight). But the problem is that if there is data to be displayed and instruction of toggling is to be sent at the same time then what to do?
I tried the code as below. Process P1 alone works OK and displays '123456789' on both lines of the LCD. But process P2 does not work (it is also showing the errors). Pls. advise.
Thanks,
Hobbyiclearner
- - - Updated - - -
The clock frequency is 25 Mhz
I wanted to know how I can flash the backlight of a 2 line character LCD module interfaced with FPGA while data is getting displayed. I am using VHDL (duration of flashing :2 secs on, 2 secs off).
A simple technique is to toggle with the display on off instructions in a seperate process by help of a loop (while counting till 2secs and then changing the value of databus after that for toggling the backight). But the problem is that if there is data to be displayed and instruction of toggling is to be sent at the same time then what to do?
I tried the code as below. Process P1 alone works OK and displays '123456789' on both lines of the LCD. But process P2 does not work (it is also showing the errors). Pls. advise.
Code:
P1: PROCESS(clk)
VARIABLE char : INTEGER := 0;
BEGIN
IF(clk'EVENT AND clk = '1') THEN
IF(lcd_busy = '0' AND lcd_enable = '0') THEN
lcd_enable <= '1';
IF(char < 22) THEN
char := char + 1;
END IF;
CASE char IS
WHEN 1 => lcd_bus <= "1000110001";
WHEN 2 => lcd_bus <= "1000110010";
WHEN 3 => lcd_bus <= "1000110011";
WHEN 4 => lcd_bus <= "1000110100";
WHEN 5 => lcd_bus <= "1000110101";
WHEN 6 => lcd_bus <= "1000110110";
WHEN 7 => lcd_bus <= "1000110111";
WHEN 8 => lcd_bus <= "1000111000";
WHEN 9 => lcd_bus <= "1000111001";
WHEN 10 => lcd_bus <= "0011000000"; -- second line
WHEN 11 => lcd_bus <= "1000110001";
WHEN 12 => lcd_bus <= "1000110010";
WHEN 13 => lcd_bus <= "1000110011";
WHEN 14 => lcd_bus <= "1000110100";
WHEN 15 => lcd_bus <= "1000110101";
WHEN 16 => lcd_bus <= "1000110110";
WHEN 17 => lcd_bus <= "1000110111";
WHEN 18 => lcd_bus <= "1000111000";
WHEN 19 => lcd_bus <= "1000111001";
WHEN OTHERS => lcd_enable <= '0';
END CASE;
ELSE
lcd_enable <= '0';
END IF;
END IF;
END PROCESS P1;
P2:PROCESS(clk) -- to switch on/off backlight
BEGIN
IF(clk'EVENT AND clk = '1') THEN
--IF(lcd_busy = '0' AND lcd_enable = '0') THEN
--lcd_enable <= '1';
for (i in 1 to 50000000*2) loop --------------ERROR 1
if (i < 50000000) then -- counting for 2 secs
lcd_bus <= "0000001000"; --display off
else
lcd_bus <= "0000001100"; -- display on for next 2 secs
end if;
end loop; -----------------------------ERROR 2
-- END IF;
END IF;
END PROCESS P2;
END behavior;
errors:
ERROR:HDLParsers:164 - "C:/Users/ESTC-AV/Desktop/test/lcd_code/lcd_example.vhd" Line 78. parse error, unexpected OPENPAR, expecting IDENTIFIER -------- ERROR 1
ERROR:HDLParsers:164 - "C:/Users/ESTC-AV/Desktop/test/lcd_code/lcd_example.vhd" Line 84. parse error, unexpected LOOP, expecting PROCESS ------------ERROR 2
Thanks,
Hobbyiclearner
- - - Updated - - -
The clock frequency is 25 Mhz