Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Flashing of backlight of 2 line character LCD display

Status
Not open for further replies.

hobbyiclearner

Full Member level 2
Joined
Oct 27, 2014
Messages
142
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Activity points
1,296
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.

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
 

For loops are unrolled in synthesis to create parallel hardware. VHDL is not a software langauge, loops are not temporal.
 

OK... so then how can I flash the back-light and keep displaying data at the same time.

Thanks,
Hobbyiclearner.
 

OK... so then how can I flash the back-light and keep displaying data at the same time.

Thanks,
Hobbyiclearner.

Arbitrate between doing one or the other. I'm not sure why you thought that the for loop would avoid arbitrating the two types of access. Create a counter for your two second timer and save the timeout in a flag and restart the timer. Arbitrate between the timeout flag and the text update access to the LCD.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top