Hi jellis00
Do you see blocks on the LCD ?
What's this line in your code?
Code:
'DEFINE SHOWDITIAL 1'
shouldn't it be showdigital ?
Next .. which port is your LCD connected to ?
If it's on PORTB like your code shows then your TRIS statement is set in the wrong direction.
You have which should actually be since you are sending to the LCD so the port should be set for output.
A nice way to remember it is that the number one looks like an i (I) which stands for Input and a zero (0 ) stands for output :-)
I feel you frustration by the way.
I spent many a night trying to get mine working :-)
If you like you are welcome to follow my example and then head back to yours once it's working and trouble-shoot the problem !
So probably the easiest is to just get it working and then trouble shoot. I used PORTD by the way :-)
By the way I have an 18F4520 (very similar)
Your problems could be a few things .. like a pause 1000 ( 1 second delay) before your code , giving time for the LCD to 'warm up' or initialize and so forth.
So I'll attach a schematic just wire it the same way and then just cut and paste my code and compile it and program your pic with it.
Here's my code
Code:
'*************************************
'Keypress display on LCD and TX to wherever
'*************************************
'Ocsillator selections here
OSCCON = $70 'Int CLK 8MHz
OSCTUNE.6 = 1 'PLL 4x
ADCON1= %00001111 '$0F = disable A/D converter
cmcon = 7
INTCON2.7 = 0 'switch pull-ups ON
'END of oscillator selections
'timer/oscillator defines
DEFINE OSC 32 '4x 8MHz
'END of timer/oscillator defines
'Port IO directions and presets for port pins begin here
'TRISX = %76543210 << tris bit order numbering
'TRISA = %11111111 'All pins are inputs
' Define port pins as inputs and outputs ...
TRISA = %00000000 'example only - TRISB = %00001111 ;Make B4-B7 outputs, B0-B3 inputs,
TRISB = %11111111 'for 4x4 keypad all input
TRISC = %10010000
TRISD = %00000000
TRISE.0 = 0
TRISE.1 = 0
TRISE.2 = 0
'End of Port IO directions and presets for port pins begin here
'variables begin here
LED var PORTd.0 ' Alias PORTD.0 to LED
'end of variables
'LCD defines begin here
DEFINE LCD_BITS 4 'defines the number of data interface lines (4 or 8)
DEFINE LCD_DREG PORTD 'defines the port where data lines are connected to
DEFINE LCD_DBIT 4 'defines the position of data lines for 4-bit interface (0 or 4)
DEFINE LCD_RSREG PORTD 'defines the port where RS line is connected to
DEFINE LCD_RSBIT 2 'defines the pin where RS line is connected to
DEFINE LCD_EREG PORTD 'defines the port where E line is connected to
DEFINE LCD_EBIT 3 'defines the pin where E line is connected
'DEFINE LCD_RWREG 0 'defines the port where R/W line is connected to (set to 0 if not used)
'DEFINE LCD_RWBIT 0 'defines the pin where R/W line is connected to (set to 0 if not used)
DEFINE LCD_COMMANDUS 2000 'defines the delay after LCDOUT statement
DEFINE LCD_DATAUS 200 'delay in micro seconds
'END of LCD DEFINES
'includes begin here
INCLUDE "modedefs.bas"
'end of includes
'Main code begins here
Pause 2000 ' Wait for LCD to startup
test:
lcdout $fe,1 'clear lcd screen
lcdout "hello world !"
high LED ' LED on
Pause 1000 ' Delay for .5 seconds
low led 'LED off
Pause 1000 ' Delay for .5 seconds
goto test
end
I used an LED on port D.0 as you can see, change the port to where your LED is connected. Get 1 blinking first then start playing with more :-)
Schematic here
[/HTML]http://www.picbasic.co.uk/forum/showthread.php?t=12179[/HTML]
All the best ..good luck
Kind regards
Dennis
Bookmarks