LCD direct connection to 28X

dj_trippn

New Member
Hi, I've read all the posts and cannot find any help with directly connecting a LCD 16x2 display to a picaxe 28X (not a module display). I am using it in 4-bit mode and I wrote my own initiliastion code. As follows. RS is on PORTC 4 and SE is on PORTB 5. And DB4-7 on PORTC 0 - 3 respectivley. DB0-3 are grounded.
init:
let pinsc = 0
pause 30

'Function Set
let pinsc = %00000010
pulsout SE,1
let pinsc = %00000010
pulsout SE,1
let pinsc = %00001100
pulsout SE,1
pause 10

'Display ON/OFF
let pinsc = %00000000
pulsout SE,1
let pinsc = %00001110
pulsout SE,1
pause 10

'Display Clear
let pinsc = %00000000
pulsout SE,1
let pinsc = %00000001
pulsout SE,1
pause 10

'Entry Mode Set
let pinsc = %00000000
pulsout SE,1
let pinsc = %00000111
pulsout SE,1

Then to write a char I use this with variable in b1;
writeChar:
let b2 = b1 & 15
let pinsc = b2
high portc RS
pulsout SE,1
let b2 = b1 / 16
let b3 = b2 & 15
let pinsc = b3 'b2 & 15
high portc RS pulsout SE,1 return

I dont know if its initilising as when I run the code the LCD goes blank for about 8 seconds then the cursor pops up and moves right one character everytime I try and write a character to the LCD display. But it does not show the character i want to display (its blank). Can anyone suggest if im initilising correctly and if my writeChar sub is correct?
Thanks, Glenn G
 

hippy

Ex-Staff (retired)
I'm afraid I don't have the time at present to look at your code in detail ( I'll try to later if you don't report it working ), but, first thought ...

Do you need to set PORTC as outputs using 'LET DIRSC=%00011111' ?
 

hippy

Ex-Staff (retired)
I've compared what you have to how I've done this in the past ...

http://www.hippy.freeserve.co.uk/picaxelc.htm

There are a few differences between what you have and what I've done.

Initialisation : The nibble sequence to initilaise 4-bit mode I've used is ...

%0011 ' $3
%0011 ' $3
%0011 ' $3
%0010 ' $2

Followed by the following byte display configurations commands ...

$28
$0C
$04
$01

Also, to write a byte ( your writeChar routine ), I output the top 4 msb's then the bottom 4 lsb's; your routine outputs the lsb's first then the msb's.
 

dj_trippn

New Member
Hi, thanks for the help. It was because I was sending the upper and lower nibbles in the wrong order. So its going now. Thank you. Next task is to get it scolling text and writing ADC readings to the LCD.
Cheers, Glenn G
 
Top