PDA

View Full Version : 18F452 and 8-bit LCD



exelanoz
- 14th December 2009, 10:59
Hello,

It must be late at night...and I am not seeing something. I have connected an LCD (20x4) via 8bit bus and it is refusing to work with the test code below, I am running it on my Easypic board. I thought it must be some other feature on the pins, so I started disabling certain features to no avail.

The LCD is ok via 4-bit bus. Checked and re-checked connections, etc.

Many thanks
AP



;Settings for 18F452

@ __CONFIG _CONFIG1H, _HS_OSC_1H
@ __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_42_2L
@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG3H, _CCP2MX_ON_3H 'CCP2 input/output is multiplexed with RC1
@ __CONFIG _CONFIG4L, _LVP_OFF_4L

DEFINE OSC 20

INTCON.7 = 0 'Global Interrupts disable
INTCON2.7 = 1 'All PORTB pull-ups are disabled
INTCON3.4 = 0 'Disable PORTB.2 External Interrupt
TRISE.4 = 0 'Disbale 'Parallel Port Slave'
ADCON0.0 = 0 'Analog OFF

Define LCD_DREG PORTD ' Port for LCD Data
Define LCD_DBIT 0 ' Use upper 4 bits of Port or Lower 4 Bits
Define LCD_RSREG PORTB ' Port for RegisterSelect (RS) bit
Define LCD_RSBIT 2 ' Port Pin for RS bit
DEFINE LCD_RWREG PORTB ' LCD read/write port
DEFINE LCD_RWBIT 3 ' LCD read/write bit
Define LCD_EREG PORTB ' Port for Enable (E) bit
Define LCD_EBIT 4 ' Port Pin for E bit
Define LCB_BITS 8 ' Using 8-bit bus
Define LCD_LINES 2 ' Using 2 line Display
DEFINE LCD_COMMANDUS 1500 ' Set command delay time in us
DEFINE LCD_DATAUS 44 ' Set data delay time in us


Pause 450 ' Let LCD Stabalize with a 450ms Pause


Main_Loop:
LCDOUT $FE, 1, "Hello World 1 2 3 "
LCDOUT $FE, $C0,"TESTING TESTING !!!!"
LCDOUT $FE, $94,"ABCDEFghijklmnopqrst"
LCDOUT $FE, $D4,"LCD 8-Bit BUS Test "

Pause 1000

GOTo Main_Loop

sayzer
- 14th December 2009, 14:22
I would change
"Define LCB_BITS 8"
to
"Define LCD_BITS 8"

And,
DEFINE LCD_COMMANDUS 1500 ' Set command delay time in us

to 2500.

__________________________________________________

exelanoz
- 15th December 2009, 07:57
Thank you very much Sayzer, it was my silly late night mistake...
Works well now :-)