PDA

View Full Version : Need help on LCD



luminas
- 7th August 2008, 17:14
I got my PIC 18F2550 blink an LED, but I cannot write to LCD
LCD is working with other PIC, no hardware issue here
PIC 18F2550, Xtal 10 Mhz

This is my code




DEFINE OSC 10
DEFINE LCD_DREG PORTB ' LCD data port
DEFINE LCD_DBIT 2 ' LCD data starting bit
DEFINE LCD_RSREG PORTB ' LCD register select port
DEFINE LCD_RSBIT 0 ' LCD register select bit
DEFINE LCD_EREG PORTB ' LCD enable port
DEFINE LCD_EBIT 1 ' LCD enable bit
DEFINE LCD_BITS 4 ' LCD data bus size
DEFINE LCD_LINES 2 ' Number lines on LCD
DEFINE LCD_COMMANDUS 2000 ' Command delay time in us
DEFINE LCD_DATAUS 50 ' Data delay time in us

skimask
- 7th August 2008, 17:31
DEFINE LCD_DBIT 2 ' LCD data starting bit
Re-Read your PBP manual concerning LCD_DBIT

Archangel
- 7th August 2008, 17:35
I got my PIC 18F2550 blink an LED, but I cannot write to LCD
LCD is working with other PIC, no hardware issue here
PIC 18F2550, Xtal 10 Mhz

This is my code


ASM
__CONFIG _CONFIG1L, _PLLDIV_10_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
__CONFIG _CONFIG1H, _FOSC_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _VREGEN_OFF_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_On_3H & _MCLRE_ON_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L

ENDASM

DEFINE OSC 10
DEFINE LCD_DREG PORTB ' LCD data port
DEFINE LCD_DBIT 2 ' LCD data starting bit <font color=red>not valid</font color>
DEFINE LCD_RSREG PORTB ' LCD register select port
DEFINE LCD_RSBIT 0 ' LCD register select bit
DEFINE LCD_EREG PORTB ' LCD enable port
DEFINE LCD_EBIT 1 ' LCD enable bit
DEFINE LCD_BITS 4 ' LCD data bus size
DEFINE LCD_LINES 2 ' Number lines on LCD
DEFINE LCD_COMMANDUS 2000 ' Command delay time in us
DEFINE LCD_DATAUS 50 ' Data delay time in us
clear
porta = 0
portb = 0
portc = 0

TRISA = %00000000 ' Set PORTA to all output
TRISB = %00000000 ' Set PORTB to all output
TRISC = %00000000 ' Set PORTC to all output

main:

LCDOUT $FE, 1
pause 100

LCDOUT $FE, 1, "Hello "
pause 100


high porta.0
pause 1000
low porta.0
pause 1000
goto main

D bit should be 0 or 4, you cannot use 2 - 5 directly this way, Darrel did do a workaround however . . .
edit: Skimask was quicker on the draw . . .

luminas
- 7th August 2008, 17:58
Thanks for your comments :)

I changed the dbit to 4 , but nothing come out of the LCD , but LED is blinking
This is my first time working with 18F2550, is there any other mistake I made?



ASM
__CONFIG _CONFIG1L, _PLLDIV_10_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
__CONFIG _CONFIG1H, _FOSC_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _VREGEN_OFF_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_ON_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L

ENDASM

DEFINE OSC 10


DEFINE LCD_DREG PORTB ' LCD data port
DEFINE LCD_DBIT 4 ' LCD data starting bit
DEFINE LCD_RSREG PORTB ' LCD register select port
DEFINE LCD_RSBIT 0 ' LCD register select bit
DEFINE LCD_EREG PORTB ' LCD enable port
DEFINE LCD_EBIT 1 ' LCD enable bit
DEFINE LCD_BITS 4 ' LCD data bus size
DEFINE LCD_LINES 2 ' Number lines on LCD
DEFINE LCD_COMMANDUS 1500 ' Command delay time in us
DEFINE LCD_DATAUS 44 ' Data delay time in us
clear
porta = 0
portb = 0
portc = 0

TRISA = %00000000 ' Set PORTA to all output
TRISB = %00000000 ' Set PORTB to all output
TRISC = %00000000 ' Set PORTC to all output


main:
LCDOUT $FE, 1
pause 100
LCDOUT $FE, 1, "Hello "
pause 100

high porta.0
pause 1000
low porta.0
pause 1000
goto main

skimask
- 7th August 2008, 17:59
Thanks for your comments :)

I changed the dbit to 4 , but nothing come out of the LCD , but LED is blinking
This is my first time working with 18F2550, is there any other mistake I made?

Change the D-Bit all you want...
If you don't change the wiring that goes with it, it ain't gonna work...

luminas
- 7th August 2008, 18:27
I forgot to change the wiring hahaha......
Now it works :) Thanks again..... have a nice day

Archangel
- 8th August 2008, 00:42
Change the D-Bit all you want...
If you don't change the wiring that goes with it, it ain't gonna work...
You know, I almost suggested that, but I thought naw, that would be rude . . . DOH!