PDA

View Full Version : LCDOUT Question



mikevandebeld
- 17th December 2011, 03:33
Hi,

This may be something that I am simply overlooking but I have spent too much time trying to figure it out. I have 4 lcds. Two are using the KS0066U controller and the other two are using the Hitachi 44780 which I believe are the same anyways. One is built in a Picdem 2 plus board and the others I have wired to the board. The built in one uses port d and a 4 bit data bus. I can get it to work no problem. I wire the other three to port b the exact same way as the built in lcd as I have the schematic to the picdem board and they will not work at all. What I am hoping is some insight on what may be going wrong for me. My exact code is below. The first set of defines is for the picdem board lcd and the other is for the wired lcd.

I am obviously missing something and any advice or suggestions would be greatly appreciated.

DEFINE OSC 4

' TRISD = %00000000
' Pause 500 ' Wait for LCD to startup
' DEFINE LCD_DREG PORTD
' DEFINE LCD_DBIT 0
' DEFINE LCD_RSREG PORTD
' DEFINE LCD_RSBIT 4
' DEFINE LCD_EREG PORTD
' DEFINE LCD_EBIT 6
' DEFINE LCD_BITS 4
' DEFINE LCD_LINES 2
' DEFINE LCD_COMMANDUS 2000
' DEFINE LCD_DATAUS 50
' Low Portd.5 'r/w low
' High Portd.7 'power on the lcd

TRISB = %00000000
PORTB = %00000000
TRISC = %00000000
PORTC = %00000000
'High Portc.1 'turn on the led
'High Portc.2
Pause 500 ' Wait for LCD to startup
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50

startup:
'High Portc.1 'status led
High Portc.1 'lcd light
Lcdout $fe, 1
Lcdout "Hello"
Pause 1000
Lcdout $fe, 1
Lcdout "World"
Low Portc.1
Pause 4000
goto startup

end

HenrikOlsson
- 17th December 2011, 07:28
Hi,
You don't say which PIC you're using so it's hard to check but it's probably a peripheral, like ADC, comparator or something else that is interfering with the port operation when used in digital mode. Check the datasheet regarding what functions are multiplexed onto the pins being used and if anything needs to be turned off.

/Henrik.

mikevandebeld
- 17th December 2011, 12:52
Hi Hendrik,

Thanks for the response. I should have mentioned what I was using. Sorry. I tried with two micros. The 18F252 and 18F452. I will try some things in regard to any interference on those pins.

mikevandebeld
- 17th December 2011, 18:04
Haha! I figured it out! The problem was that I had the first bit of the lcd 4 bit bus connected to portb bit 2. I overlooked the fact that one can only start the bus at bit 0 or 4 on the ports.

Thanks Hendrik for your assistance!

HenrikOlsson
- 17th December 2011, 20:37
And even if you COULD start at bit 2 your DEFINE still said bit 0 so it wouldn't have worked anyway.
I'm glad you figured it out - sometimes it helps to just step away from it for a while. Well done!

/Henrik.