LCD not working with 18F4550
Hi all,
I started playing around with the 18F4550, read all the threads I could find on USB, triple-checked the configs, made sure DEFINES were in caps, but now I'm stumped on the most basic operation.
- 18F4550 with 20MHz crystal
- Lab X1 experimental board powered by wall adapter
- PBP 2.60C
- MicroCode Studio Plus v2.2.1.1
- MPLAB MPASM
Quote:
ASM ; 18F4550, 20mhz crystal
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _CCP2MX_OFF_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
__CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
ENDASM
DEFINE OSC 48
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
TRISD = 0
TRISE = 0
PAUSE 1000
LCDOUT $FE,1,"LabX1 18F4550"
end
Nothing comes out on the LCD.
The LCD works fine, I used it for the Lab X1 examples I just added in Code Examples. I can get LEDs to blink back and forth, so I know the PIC can be programmed properly, but that's about it.
(gets ready for point-and-laugh session)
Robert
:(
Re: LCD not working with 18F4550
Hi Robert,
Analog functions on PortE perhaps?
Also, you say that you have a 20Mhz x-tal but then you DEFINE OSC 48, is that correct? I know the oscillator on the USB devices are a bit different and I'm not saying you've got it wrong but since it doesn't work perhaps it's worth looking into. Do a simple blink-a-led with a PAUSE 500 or whatever and verify that the timing looks OK.
/Henrik.
Re: LCD not working with 18F4550
You may need to initialize the display by sending a clear screen command, then pause 500ms or more before trying to write to it. I have had better luck with the displays doing this. Would also be worth checking the heart beat to verify osc settings like Henrik mentioned.
Re: LCD not working with 18F4550
Quote:
Originally Posted by
HenrikOlsson
...
Analog functions on PortE perhaps?
...
Hi Henrik,
Tried ADCON1=7 with no success.
Quote:
Originally Posted by
HenrikOlsson
...
Also, you say that you have a 20Mhz x-tal but then you DEFINE OSC 48, is that correct? I know the oscillator on the USB devices are a bit different and I'm not saying you've got it wrong but since it doesn't work perhaps it's worth looking into.
...
That's the way Darrel does it in his DT HID260 example.
Quote:
Originally Posted by
HenrikOlsson
...
Do a simple blink-a-led with a PAUSE 500 or whatever and verify that the timing looks OK.
...
That was the first thing I did with this chip when I couldn't get the LCD working.
Quote:
Originally Posted by
Demon
...
The LCD works fine, I used it for the Lab X1 examples I just added in Code Examples. I can get LEDs to blink back and forth, so I know the PIC can be programmed properly, but that's about it.
...
Quote:
Originally Posted by
spcw1234
...
You may need to initialize the display by sending a clear screen command, then pause 500ms or more before trying to write to it.
...
Tried, still nothing on LCD.
Current code:
Quote:
ASM
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _CCP2MX_OFF_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
__CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
ENDASM
DEFINE OSC 48
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
ADCON1 = 7
TRISD = 0
TRISE = 0
WSLOOP var byte ' Loop counter
PAUSE 1000
LCDOUT $FE,1
PAUSE 2000
LCDOUT $FE,1,"LabX1 18F4550"
PORTD = %00000001 ' Turn 1st LED on
pause 100 ' Short delay
CYCLE:
for wsloop = 1 to 7 ' Turn on next LED from right to left
PORTD = PORTD << 1
pause 100
next
for wsloop = 1 to 7 ' Turn on next LED from left to right
PORTD = PORTD >> 1
pause 100
next
GOTO CYCLE
END
The LEDs blink back and forth but still no love from the LCD.
Re: LCD not working with 18F4550
Quote:
Tried ADCON1=7 with no success.
Try 15. 7 only takes care of 8-12.
DATA sheets are your friend.
Please read the chips DATA sheet and make it happy :)
Re: LCD not working with 18F4550
Quote:
Originally Posted by
mackrackit
Try 15. 7 only takes care of 8-12.
DATA sheets are your friend.
Please read the chips DATA sheet and make it happy :)
GAAAAAAAAAAAA!!!!!
That was it! You have no idea how much of that datasheet I went through, but I missed that part about ADCON1 being different. If it's one thing I learned from Steve, it's RTFM.
Thanks!
:)
Re: LCD not working with 18F4550
Re: LCD not working with 18F4550
sorry and LCDOUT $fe,$80,"LabX1 18F4550"
Re: LCD not working with 18F4550
Quote:
Originally Posted by
selim
try ADCON1 = 001111
He did and it fixed it. Did you not see that post?