Programming E-block LCD Display
Programming E-block LCD Display
Can anybody give me the step by step guide on how to program E-block LCD Display.
I am programming in VHDL, If anyone have an example code even that would be much appreciated.
Thanks
I am programming in VHDL, If anyone have an example code even that would be much appreciated.
Thanks
- Steve
- Matrix Staff
- Posts: 3431
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
Re: Programming E-block LCD Display
The datasheet for the driver is attached. Also note that the E-Block needs to use the 4-bit mode.
And here is a list of the commands to put it into 4-bit mode and clear the display:
And here is a list of the commands to put it into 4-bit mode and clear the display:
Code: Select all
0x33
0x32
0x2c
0x06
0x0c
0x01
0x02
- Attachments
-
- KS0066u - lcd driver.pdf
- (450.1 KiB) Downloaded 554 times
Re: Programming E-block LCD Display
I am actually using matrix multimedia EB005-30-3 LCD module. According to it's manual I have to send commands 4bit sequence.
I am using a push button and each time it pressed the 4 bit code enters to LCD. However it doesn't seem to work.
Could you please let me know how to feed the 4 bit codes in to LCD. (Example VHDL code would be great!!)
I am using a push button and each time it pressed the 4 bit code enters to LCD. However it doesn't seem to work.
Could you please let me know how to feed the 4 bit codes in to LCD. (Example VHDL code would be great!!)
Re: Programming E-block LCD Display
I have now had my HP-488 for a couple of days and it's fantastic, but I have suffered the torments of hell trying to get the LCD working properly. Just in case there are other people out there going through the same thing, I'd like to point out a critical piece of information that is missing from both the HP-488 PDF and the Powertip PDF. In fact the only place I found this information properly explained was in the datasheet for the Hitachi HD44780. It's not even explained clearly in the Samsung KS0066U PDF.
On power up, the LCD is in 8-bit mode which means it must be set to 4-bit mode. Now, if you're like me, you will have written a routine to send a byte as two nibbles in 4-bit mode. The problem is that this doesn't work for the first instruction (Function Set) which must be sent. The proper procedure seems to be that you must first send 0010 to make the LCD go into 4-bit mode. After that you must send 0010xxxx in the usual 4-bit way. In other words, the first time you write to the LCD after power-up, you must write THREE nibbles, not the usual two.
The behaviour if you don't do this is erratic and confusing. Sometimes it works and sometimes it doesn't. Even worse, once you understand and implement the above, pressing reset will mess things up again because reset doesn't reset the LCD, only the MPU -- now the LCD is already in 4-bit mode and the three-nibble trick messes it up. I solved this by using the RCON register to detect power-on and do the three-nibble trick only on power-on, not on normal reset.
I'm writing this not only to get it off my chest
but also in the hope that it saves someone else 16 hours of their life going mental trying to work out why power-up behaviour is different to reset behaviour, and trying to work out why sending certain characters works but not others.
I've now written a set of routines in assembler for controlling the LCD. I'd be happy to give them to anyone who is having trouble with this. If you need help, reply to this and I'll send you the code.
John
On power up, the LCD is in 8-bit mode which means it must be set to 4-bit mode. Now, if you're like me, you will have written a routine to send a byte as two nibbles in 4-bit mode. The problem is that this doesn't work for the first instruction (Function Set) which must be sent. The proper procedure seems to be that you must first send 0010 to make the LCD go into 4-bit mode. After that you must send 0010xxxx in the usual 4-bit way. In other words, the first time you write to the LCD after power-up, you must write THREE nibbles, not the usual two.
The behaviour if you don't do this is erratic and confusing. Sometimes it works and sometimes it doesn't. Even worse, once you understand and implement the above, pressing reset will mess things up again because reset doesn't reset the LCD, only the MPU -- now the LCD is already in 4-bit mode and the three-nibble trick messes it up. I solved this by using the RCON register to detect power-on and do the three-nibble trick only on power-on, not on normal reset.
I'm writing this not only to get it off my chest

I've now written a set of routines in assembler for controlling the LCD. I'd be happy to give them to anyone who is having trouble with this. If you need help, reply to this and I'll send you the code.
John
- Steve
- Matrix Staff
- Posts: 3431
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
Re: Programming E-block LCD Display
There should be no need to read RCON. We have examples in Assembly, C and in Flowcode that control the LCD fine without using RCON.
The following ASM program (for the 16F88) is on our Assembly for PICmicros CD and shows one way to control the LCD:
The following ASM program (for the 16F88) is on our Assembly for PICmicros CD and shows one way to control the LCD:
Code: Select all
; TUTA29.ASM 27SEP07
; illustrating use of Timer and LCD set up
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; Configuration data
; PICmicro MCU type: 16F88
; Oscillator: XTAL mode, FAST, VR1 - your choice of setting
; LCD display: on
; 7-segment display: off
; Version 3 board settings: J14 links: Digital
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
; The following lines embed configuration data into the PICmicro
LIST P=16F88
__CONFIG H'2007', H'3F6A' ; HS mode
__CONFIG H'2008', H'3FFC' ; Clock Fail-Safe disabled
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#DEFINE PAGE0 BCF STATUS,5
#DEFINE PAGE1 BSF STATUS,5
OPSHUN EQU H'81'
PCL EQU H'02'
STATUS EQU H'03'
PORTA EQU H'05'
TRISA EQU H'85'
PORTB EQU H'06'
TRISB EQU H'86'
INTCON EQU H'0B'
LOOP EQU H'20' ;loop counter 1 - general
LOOPA EQU H'21' ;loop counter 2 - LCD use only
CLKCNT EQU H'22' ;125 secs counter
STORE EQU H'27' ;general store
RSLINE EQU H'2F' ;bit 4 RS line flag for LCD
W EQU 0
F EQU 1
ORG 0 ; Reset vector
GOTO 5 ; Goto start of program
ORG 4 ; Interrupt vector
GOTO 5 ; Goto start of program
ORG 5 ; Start of program memory
CLRF PORTA
CLRF PORTB
PAGE1 ; PAGE1
CLRF H'9B' ; Clear the ANSEL register
CLRF TRISA ;Port A0-A4 as output
CLRF TRISB ;Port B0-B7 as output
MOVLW B'00000110' ;set timer ratio 1:128
MOVWF OPSHUN
PAGE0 ; PAGE0
GOTO SETUP ;bypass table
TABLCD ADDWF PCL,F ;LCD initialisation table
RETLW B'00110011' ;initialise lcd - first byte
RETLW B'00110011' ;2nd byte (repeat of first)
RETLW B'00110010' ;set for 4-bit operation
RETLW B'00101100' ;set for 2 lines
RETLW B'00000110' ;set entry mode to increment each address
RETLW B'00001100' ;set display on, cursor off, blink off
RETLW B'00000001' ;clear display
RETLW B'00000010' ;return home, cursor & RAM to zero
;end initialisation table
MESSAG ADDWF PCL,F
RETLW 'G'
RETLW 'R'
RETLW 'E'
RETLW 'E'
RETLW 'T'
RETLW 'I'
RETLW 'N'
RETLW 'G'
SETUP CALL PAUSIT ;perform first 1/5th sec delay
LCDSET CLRF LOOP ;clr LCD set-up loop
CLRF RSLINE ;clear RS line for instruction send
LCDST2 MOVF LOOP,W ;get table address
CALL TABLCD ;get set-up instruction
CALL LCDOUT ;perform it
INCF LOOP,F ;inc loop
BTFSS LOOP,3 ;has last LCD set-up instruction now been done?
GOTO LCDST2 ;no
CALL PAUSIT ;yes, perform second 1/5th sec delay
;to allow final LCD command to occur
;(it takes longer than the rest)
LCDMSG CLRF LOOP ;clear loop
BSF RSLINE,4 ;set RS for data send
LCDMS2 MOVF LOOP,W ;get table address
CALL MESSAG ;get message letter
CALL LCDOUT ;show it
INCF LOOP,F ;inc loop
BTFSS LOOP,3 ;has last LCD letter been sent?
GOTO LCDMS2 ;no, so repeat for next one
NOMORE GOTO NOMORE ;yes, so hold here ad infinitum!
LCDOUT MOVWF STORE ;temp store data
MOVLW D'250' ;set minimum time between sending full bytes to
MOVWF LOOPA ;LCD - value of 250 seems OK for this prog with
DELAY DECFSZ LOOPA,F ;XTAL clk of upto 20MHz
GOTO DELAY ;keep decrementing LOOPA until zero
CALL SENDIT ;send MSB
CALL SENDIT ;send LSB
RETURN
SENDIT SWAPF STORE,F ;swap data nibbles
MOVF STORE,W ;get data byte
ANDLW H'0F' ;get nibble from byte (LSB)
IORWF RSLINE,W ;OR the RS bit
MOVWF PORTB ;output the byte
BSF PORTB,5 ;set E line high
BCF PORTB,5 ;set E line low
RETURN
PAUSIT MOVLW D'30' ;set delay counter to 30
MOVWF CLKCNT ;(for 1/150th sec x 30)
CLRF INTCON ;clear interupt flag
PAUSE ;initial 1/5th sec wait before setting up LCD
BTFSS INTCON,2 ;has a timer time-out been detected?
GOTO PAUSE ;no
BCF INTCON,2 ;yes
DECFSZ CLKCNT,F ;dec counter, is it zero?
GOTO PAUSE ;no
RETURN ;yes
END ;final line
Re: Programming E-block LCD Display
Thanks Steve,
I didn't mean my message to come across as a complaint, more just as a way of sharing what I've learned. There's no one here that I can share this stuff with and I'm sure I'm not alone with that. I must admit I was pretty sure my RCON trick was a hack but I couldn't figure out a better way.
I studied the code you posted and I can see the trick -- the first few LCD instructions are cleverly designed to set the LCD to 8-bit mode and back to 4-bit mode regardless of what mode it's in at that moment. Ingenious but it certainly took some mental effort to understand how that works. I suppose that's what programming at this level is all about, making miracles happen with next to no hardware. I've taken my RCON rubbish out and used your initial byte stream and of course it works like a dream.
Thanks,
John
I didn't mean my message to come across as a complaint, more just as a way of sharing what I've learned. There's no one here that I can share this stuff with and I'm sure I'm not alone with that. I must admit I was pretty sure my RCON trick was a hack but I couldn't figure out a better way.

Thanks,
John
Re: Programming E-block LCD Display
Hi,
As a beginner, I am still trying to get my head around this problem. John- if you have the code in VHDL it would be very helpful and please send it to anmsing@yahoo.co.uk.
I am using the E-Blocks - EB005-30-03 LCD module and it got only 4 data pins. (manual is available at http://matrixmultimedia.com/product.php ... PHPSESSID=)
In VHDL, I have to define the port as a 4bit vector in order to assign the pins. Therefore, there is no way I could use an 8 bit word to send in to data pins.
Please clarify bit more how I could parse the bit streams to the EB005-30-03 LCD module.
As a beginner, I am still trying to get my head around this problem. John- if you have the code in VHDL it would be very helpful and please send it to anmsing@yahoo.co.uk.
I am using the E-Blocks - EB005-30-03 LCD module and it got only 4 data pins. (manual is available at http://matrixmultimedia.com/product.php ... PHPSESSID=)
In VHDL, I have to define the port as a 4bit vector in order to assign the pins. Therefore, there is no way I could use an 8 bit word to send in to data pins.
Please clarify bit more how I could parse the bit streams to the EB005-30-03 LCD module.
Re: Programming E-block LCD Display
Hi asa,
Looks like I already answered your other message.
I'm sorry but I don't actually know what VHDL is. I'm using PIC18 assembler. If you want the assembler code let me know. The thing with this 4-bit connection is that you have to send the byte in two parts. First the high 4 bits and then the low 4 bits. There is a special trick for the first instruction after reset which Steve showed me how to do properly. Let me know if I can be of any further help.
John
Looks like I already answered your other message.

John
Re: Programming HP-488 LCD Display
I have been using HP-488 BOARD
The thing is I have checked the LCD configuration,
I am using start nibble
RB0 ,1,2,3 for data means(LOWER NIBBLE)
RB4 for RS
RB7 for EN
USING J19 AND J21 to change the default bits for LVP and LCD.
Now in programming I am sending only 4 bits to PORTB.
Previously only one cursor on the LCD was blinking now instead of LCD only LEDs are becoming on.
Why this board is too much complicated.I really will not recommend any one to use this product too much problem
can any one send me c language code for PIC18?please
The thing is I have checked the LCD configuration,
I am using start nibble
RB0 ,1,2,3 for data means(LOWER NIBBLE)
RB4 for RS
RB7 for EN
USING J19 AND J21 to change the default bits for LVP and LCD.
Now in programming I am sending only 4 bits to PORTB.
Previously only one cursor on the LCD was blinking now instead of LCD only LEDs are becoming on.
Why this board is too much complicated.I really will not recommend any one to use this product too much problem

can any one send me c language code for PIC18?please