40x1 and parallel LCD in 4bit mode.

ZL2UFW

New Member
Hi, I cannot get a LCD display to work with a 40x1 picaxe. The board is OK as the display works with a 40x picaxe and I have had a scope on all of the data pins and there is data on the pins from the 40x1.
I have also tried increasing the delays in the "init" subroutine. Both are using a 4mhz resonator.
Any ideas. Thanks, Terry.
 

hippy

Ex-Staff (retired)
Which 40X1 Firmware is it and whose LCD driving code are you using ?

And also - In what way doesn't it work ? Nothing displayed ? Black blobs ? Wrong characters ?

Edited by - hippy on 27/06/2007 20:23:42
 

ZL2UFW

New Member
Hi Hippy.
40x1 firmware is a.0 and I have tried your code (after changing the get symbol to get_)
if I connect d0-d3 data line to gnd I get black blobs, if I leave them floating or tie them high I get garbage.
I have also tried the following init routine.

init:
pause 800
pins=0
b4=0
pause 400
pins=48
pulsout 3,10
pause 40
pulsout 3,10
pause 4
pulsout 3,10
pause 4
pins=32
pause 4
pulsout 3,10
pause 4
pulsout 3,10
pause 4
pins=128
pulsout 3,10
pause 4
b1=14
gosub wrins
return

I am sure the problem is the the Init sequence.

Thanks....Terry
 

hippy

Ex-Staff (retired)
There's a problem with code generation for Firmware A.0 ...

http://www.rev-ed.co.uk/picaxe/forum/topic.asp?topic_id=7266 ( <A href='http://www.rev-ed.co.uk/picaxe/forum/topic.asp?topic_id=7266' Target=_Blank>External Web Link</a> )

This causes incorrect operation for all 'pins=' statements. A workround until a new compiler arrives is to change all'pins=whatever' to -<code><pre><font size=2 face='Courier'>pins = whatever ^ $80 </font></pre></code>
 

ZL2UFW

New Member
Thanks Hippy. That fixed the problem but I will have to rethink how I will resolve it in my software. The code was originally written for a chip with only 16 gosubs. I may well use a hex inverter to fix the problem in this project so I can user the code again in future chips.

Many Thanks....Terry
 

Tom2000

Senior Member
Here's one way of applying Hippy's fix that's somewhat maintainable:



<code><pre><font size=2 face='Courier'>

SendDataByte:

#ifdef A0_firmware

; Compensates for the Output7 inversion bug in A.0 firmware

pins = dat &amp; %11110000 | rsbit ^ %10000000 ; Put MSB out first
pulsout E,1 ; Give a 10uS pulse on E
pins = dat * %00010000 | rsbit ^ %10000000 ; Put LSB out second
pulsout E,1 ; Give a 10uS pulse on E
rsbit = RSDatMask ; Send to Data register next

#else

pins = dat &amp; %11110000 | rsbit ; Put MSB out first
pulsout E,1 ; Give a 10uS pulse on E
pins = dat * %00010000 | rsbit ; Put LSB out second
pulsout E,1 ; Give a 10uS pulse on E
rsbit = RSDatMask ; Send to Data register next

#endif

return




</font></pre></code>

Somewhere in the preamble of your program, add this line:

#define A0_firmware

When the compiler deals with that subroutine, it will compile either the version that compensates for the bug or the correct version. When you're building something with a (hopefully) fixed chip, just delete or comment out the #define... line.

Tom


Edited by - Tom2000 on 29/06/2007 15:47:28
 

D n T

Senior Member
Look on a forum fo january 7th that D n T posted (me)

I am using the portC pins to run it.

This is the good bits from it:
( I cut and pasted it to a text file and then from that to here)

ONCE AGIAN THANKS TO HIPPY



I'm playing with Hippys LCD code on a 40x and want to use the portc pins instead of the normal output pins, I believe it will make programming easier.
I don't know how to convert this line to portc...

pulsout EN,1

EN is the symbol for output 3

I need to find out how to do the let pins or the let dirs in a portc situation.

alternately , Hippy how do I do it, please


Fowkc Posted - 7 January 2007 15:44
--------------------------------------------------------------------------------
The manual says it's not possible:

&quot;It is not possible to access the portc pins with any other 'output' type commands (sound, serout, pulsout etc).&quot; (axe001_xparts.pdf)

Perhaps there's a way to do it by poking approprite registers?

Phil75 Posted - 7 January 2007 17:40
--------------------------------------------------------------------------------
you could use

high portc 3
pause 1
low portc 3


Edited by - Phil75 on 07/01/2007 17:44:51

Fowkc Posted - 7 January 2007 17:59
--------------------------------------------------------------------------------
That will cause a 1ms = 1000us pause on the PORTC pin, whereas the PULSOUT command works in 10us units.

You can, however, use PULSOUT to create &quot;dummy&quot; pauses of 10us units. So:


HIGH PORTC 1PULSOUT 1,1 'Dummy pause on normal outputsLOW PORTC 1

will do the job. However, this means you're effectively using two pins instead of one, and there might be issues with the processing time of the HIGH and LOW statements depending on your application.
Phil75 Posted - 7 January 2007 18:36
--------------------------------------------------------------------------------
Yep know it is 1ms but if it's for an occasional clock then might not matter too much. Or this

high portc 3
for b0=0 to n:next
low portc 3


hippy Posted - 7 January 2007 19:6
--------------------------------------------------------------------------------
The 'E' strobe is only 10uS anyway, so there's no need for any delay. A straight-forward ...
High PortC 3 Low PortC 3
should do the job.
kym Posted - 8 January 2007 1:5
--------------------------------------------------------------------------------
DnT Try this,have MODIFIED Hippy's code

; HIPPY'S MODIFIED CODE FOR 28X LCD PORTC

SYMBOL RS = 2 ; 0 = Command 1 = Data
SYMBOL DB4 = 4 ; LCD Data Line 4
SYMBOL DB5 = 5 ; LCD Data Line 5
SYMBOL DB6 = 6 ; LCD Data Line 6
SYMBOL DB7 = 7 ; LCD Data Line 7

SYMBOL RSCMDmask = %00000000 ; Select Command register
SYMBOL RSDATmask = %00000100 ; Select Data register

SYMBOL get = b10
SYMBOL bite = b11
SYMBOL rsbit = b12

let dirsc=%11111100 ' Set PORTC 6 Outputs and 2 Inputs

PowerOnReset:

GOSUB InitialiseLcd

DisplayTopLine:

pause 200
EEPROM 6,(&quot;Hello&quot;)

FOR get = 6 TO 10
READ get,bite
GOSUB SendDataByte
NEXT

MoveCursorToStartOfSecondLine:

let bite = $C0
GOSUB SendCmdByte

DisplayBottomLine:

EEPROM 11,(&quot;World!&quot;)

FOR get = 11 TO 16
READ get,bite
GOSUB SendDataByte
NEXT

END

InitialiseLcd:

FOR get = 0 TO 5
READ get,bite
GOSUB SendInitCmdByte
NEXT

' Nibble commands - To initialise 4-bit mode

EEPROM 0,( $33 ) ; %0011---- %0011---- 8-bit / 8-bit
EEPROM 1,( $32 ) ; %0011---- %0010---- 8-bit / 4-bit

' Byte commands - To configure the LCD

EEPROM 2,( $28 ) ; %00101000 %001LNF00 Display Format
EEPROM 3,( $0C ) ; %00001100 %00001DCB Display On
EEPROM 4,( $06 ) ; %00000110 %000001IS Cursor Move

; L : 0 = 4-bit Mode 1 = 8-bit Mode
; N : 0 = 1 Line 1 = 2 Lines
; F : 0 = 5x7 Pixels 1 = N/A
; D : 0 = Display Off 1 = Display On
; C : 0 = Cursor Off 1 = Cursor On
; B : 0 = Cursor Steady 1 = Cursor Flash
; I : 0 = Dec Cursor 1 = Inc Cursor
; S : 0 = Cursor Move 1 = Display Shift

EEPROM 5,( $01 ) ; Clear Screen

RETURN


SendInitCmdByte:
pause 15 ; Delay 15mS

SendCmdByte:

rsbit = RSCMDmask ; Send to Command register

SendDataByte:
let b3=bite &amp; %11110000 | rsbit ; Put MSB out first
pinsc =b3
high portc 3 ; Pulseout on PIN 3
low portc 3
let b3=bite * %00010000 | rsbit ; Put LSB out second
pinsc =b3
high portc 3 ; Pulseouton PIN 3
low portc 3

rsbit = RSDATmask ; Send to Data register next

RETURN

B3 can be any variable , This is needed because this line don,t work on PORTC.

Kym



Edited by - D n T on 30/06/2007 13:18:30
 

kenmac

Member
I had problems using &quot;high portC x/low portC x&quot; with one model LCD.
See my post yesterday
&quot;LCD Enable - problem with using portC output&quot;

kenmac
 

ZL2UFW

New Member
Thanks for the reply's..I have it up and running. I needed some of the functions of portc eg i2c so I ended up using a hex inverter to solve the problem.
Cheers....Terry
 

kym

Member
If you get a line of black squares,
this is because the LCD has not initialised
properly, usually to do with the pauses:
Too long or too short, depending on the make
of the LCD, pauses between pulseouts and
let pins= commands can usually be removed:

The pause after init: is the one to adjust.

Kym
 
Top