Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers

Working with LCD

Altera_Forum
Honored Contributor II
907 Views

Pardon how amateur this looks, I havent had much practice 

 

Here is the code I wrote, as far as I can tell I've wired everything up as documented in the code, but when I try to run it, the bottom Blocks of the LCD go solid, like the other forums said should happen before it's initialized. But I see no response at the LCD. It may have looked neater if Freddy Krueger had soldered it, but I am pretty sure I didn't damage it.  

 

This is a standrd LCD from sparkfun. I am working with the Cyclone II starter Kit, and I am a reformed Visual Basic Person, so thats why I seem to write code a little different.  

 

Please tell me if anything you see would make this not work, or if you have any tips on how to do it more effeciently, I know it looks really amateur at this point.  

 

module LCD_PRINT(IOBUS,deb2,clk,STC);  

 

output [30:0] IOBUS;  

// output pins  

input [3:0] deb2;  

//debounce signal, I step through this with the buttons so I can test signals  

input clk;  

// standard clock from starter board (27mhz)  

reg [7:0] outc;  

// 8 bits going out to data db0-db7  

reg RS;  

// register select  

input [3:0] STC;  

// STC count incremented from debounce, its on 7seg LCD for testing  

reg [16:0] count;  

// timer for leaving E high for a while, then shutting it  

reg writing;  

// reg for E on or off  

 

// debounce comes as a pulse from another module 

// this part generates my E writing signal to LCD 

// Simulation seems to work 

 

always@(posedge clk)  

begin  

if (deb2!=4'b0000 & count==0)  

begin  

count=1;  

writing=0;  

end  

if (count>0 & count!=1000)  

begin  

count=count+1;  

end  

if (count>200 & count !=1000)  

begin  

writing=1;  

end  

if (count==1000)  

begin  

count=0;  

writing=0;  

end  

 

//this segment sets output for each data sent, STC is count that is incrementd in the debounce module 

if (STC==1)  

begin  

outc=8'b00111000;  

// send 38h for 8 bit mode  

RS=0;  

end  

if (STC==2)  

begin  

outc=8'b00001111;  

// send 0Fh for "Display On"  

RS=0;  

end  

if (STC==3)  

begin  

outc=8'b00000001;  

// send 01h to clear  

RS=0;  

end  

if (STC==4)  

begin  

outc=8'b00001111;  

RS=1;  

end  

if (STC==5)  

begin  

outc=8'b01111111;  

RS=1;  

end  

if (STC==6)  

begin  

outc=8'b11111111;  

RS=1;  

end  

if (STC==7)  

begin  

outc=8'b01010101;  

RS=1;  

end  

end  

assign IOBUS[0]=0;  

// IOBUS[0]=R/W always at 0 for writing  

assign IOBUS[1]=RS;  

// IOBUS[1]= RS 0 for command, 1 for data  

assign IOBUS[2]=writing;  

// IOBUS[2]=RE  

 

assign IOBUS[3]=outc[0];  

assign IOBUS[4]=outc[1];  

assign IOBUS[5]=outc[2];  

assign IOBUS[6]=outc[3];  

assign IOBUS[7]=outc[4];  

assign IOBUS[8]=outc[5];  

assign IOBUS[9]=outc[6];  

assign IOBUS[10]=outc[7];  

 

endmodule 

_________________ 

It's good to be evil
0 Kudos
0 Replies
Reply