From 6bcf34867ab92f2640f3f292b5235a7e05f27846 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 27 Nov 2015 11:26:17 +0100 Subject: [PATCH] Adding improved CS handling for LCD control. --- code/lcd.vhd | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/code/lcd.vhd b/code/lcd.vhd index c033ce1..371562f 100644 --- a/code/lcd.vhd +++ b/code/lcd.vhd @@ -316,6 +316,7 @@ fsm : process begin state <= RSTCLEAR2; if cnt = 320*240*2-1 then state <= RSTFINISH; + timer <= (others => '0'); end if; end if; when RSTCLEAR2 => @@ -327,6 +328,7 @@ fsm : process begin state <= RSTCLEAR; if cnt = 320*240*2-1 then state <= RSTFINISH; + timer <= (others => '0'); end if; end if; when RSTFINISH => @@ -335,8 +337,17 @@ fsm : process begin posrow <= 0; datapos <= 32; --start of text section varcnt <= 4; --no nibble active - state <= WAITSTART; - + if spi_idle = '1' then + CS <= '1'; + if timer(4) = '1' then --set CS again early enough + CS <= '0'; + end if; + if timer = x"0000014" then + state <= WAITSTART; + end if; + else + timer <= (others => '0'); + end if; -------------------------------------------------------------- -- Write text from memory -------------------------------------------------------------- @@ -370,6 +381,7 @@ fsm : process begin state <= WAITSTART1; elsif curdata = x"00" then --end of string state <= RSTFINISH; + timer <= (others => '0'); else --error, skip datapos <= datapos + 1; state <= WAITSTART1; -- 2.43.0