Nokia 3310 interface?

eclectic

Moderator
I've been following this thread;
http://www.picaxeforum.co.uk/showthread.php?t=9797

I've tried both Texy's code in post #9 and the original code, listed here;
http://homepage.ntlworld.com/c.lewis19/nokia.htm

Picaxes are either 18X or 28X1.

I'm using a 3.3 ldo to provide power, and making connections via 1k resistors.
There's 3.30v on Nokia pin 1.
I've checked continuity: all eight contacts look OK.
"Separation" / track-bridging looks and meters OK.
LED's on out 0-4 happily twinkle.

But, the screen is still blank!

Possibilities.

1. I can't solder for toffee, and I've botched something.
Highly probable, and it's happened before.

But, just in case,

2. There is a “hidden” contrast-control code.
I've seen mention of 80h – Ffh on searches, but in assembler.
Is it accessible from Picaxe?

3. Am I using the wrong value capacitor, or, is there an alternative circuit?

4. I've wasted a whole £1 on the GLCD!

Any other ideas please folks?

E (and oe)
 

Attachments

Last edited:

westaust55

Moderator
A bit off searching finds that C3 is not essential.
Others have used a 100nF capacitor though Texy suggests 1 to 10uF is okay.
C3 Capacitor 100 nF not mandatory; needed, if display is unstable
(eg: only every 2nd row is visible, ...)

Texy also states:
I experience two failures before I was successful.
Not 100% clear whether these were faulty on purchase (through Ebay - Texy mentions readily available thru Ebay?). He mentions damaging 2 while working with them.
Recall you mentioned you bought several. In that case, have you tried another display?


Edit:
Do you need a backlight connected to see the display?
Some LCD displays are virtually invisible without but others are dull but can still be seen when backlight is off.
Attached diagram shows a backlight circuit
 

Attachments

Last edited:

westaust55

Moderator
e,

While difficult when do not have a 3310 screen, but maybe you could post your code and we can have a look for obvious errors.

Even the "corrected" code posted by Texy has at least one typo that I spotted. (has a space in the middle of the first "47"):
Code:
EEPROM 15,
(24,26,28,30,31,33,34,36,38,39,41,42,43,44,45,46,[B][COLOR="Red"]4 7[/COLOR][/B],47,47,47,47,47,47
,46,45,44,43,42)


EDIT (Add-in) 1:
A lot of conflicting info avalaible out there makes it hard to know what is right.
here is a link sugegsting 5Vdc supply requierd (Care needed here)
There is a schematic for the 16F877 PIC showing 5Vdc to the 33`0 LCD

The Philips datasheet for PCD8544 indicaters max of 3.3Vdc for Vdd1 and Vdd2. And the absolute MAX rating for Vdd is 7Vdc

The zip file has a C language code showing steps (in C) but indicates the codes to initialise.
http://www.geocities.com/dariuskrail20/nokia3310lcd.html

The extracted intialisation code is:
Code:
}

void initlcd(void)
{
	_RES = 1;		// Set _RES HIGH.
	_SCE = 1;		// Disable Chip.
	_RES = 0;		// Reset the LCD.
	DelayMs(100);	// Wait 100ms.
	_RES = 1;		// Awake LCD from RESET state.

	writecom(0x21);		// Activate Chip and H=1.
	writecom(0xC2);		// Set LCD Voltage to about 7V.
	writecom(0x13);		// Adjust voltage bias.
	writecom(0x20);		// Horizontal addressing and H=0.
	writecom(0x09);		// Activate all segments.
	clearram();			// Erase all pixel on the DDRAM.
	writecom(0x08);		// Blank the Display.
	writecom(0x0C);		// Display Normal.
	cursorxy(0,0);		// Cursor Home.
}

void writecom(char command_in)
{
	D_C = 0;				// Select Command register.
	_SCE = 0;				// Select Chip.
	clockdata(command_in);	// Clock in command bits.
	_SCE = 1;				// Deselect Chip.	
}
The first EEPROM command for intialissation seems okay. The data from
EEPROM 0,(33,197,6,19,32,12) represent:

33 = Activate Chip and H=1
197 = Set LCD voltage (192 = 7.02V & 197 = 7.32V)
6 = Temperature control = temp coefficient 2 = 17mV/K
19 = Adjust Bias System to 1:48
32 = Horizontal addressing and H=0.
12 = Display Normal. (H must =0 for display control)

Edit (Add-in) 2:
Contrast is adjusted by a combination of the Vlcd and the temp compensation.
Some M/C code examples I found had $A9 = 169 giving an Vlcd voltage of 5.52V As you say, The value can be set to anything between $80 and $FF.
80h being minimum contrast and $FF maximum. The msb is not used to calculate Vlcd so the range is from 3.06 to 10.68V

From the datasheet, “Due to the temperature dependency of the liquid crystals’ viscosity, the LCD controlling voltage VLCD must be increased at lower temperatures to maintain optimum contrast.”
 
Last edited:

eclectic

Moderator
WestAus.
Genuine thanks for the research you've done.

I'll wire up another LCD tomorrow,
and have another go.

e.
 

Texy

Senior Member
My 1st picaxe project is far from over but I've got the 3310 LCD working fine, altho slow to write too. I'll post some fully working code tomorrow;)
incidently some of the things quoted as by me aren't - I've only connected up 1 module so far, and its still working - and its connected to my main picaxe supply voltage using 4 AA nimhs. I measured it at 5.5 volts at one point, maybe I got lucky!

Texy
 

Michael 2727

Senior Member
I have a few NOKIA Displays, I'd try to get them going if
I could SEE the connectors, let alone SOLDER them, ~ ;o)

Need x10 ~OO~ or --O

Even though those phones/displays are cheap to buy, I got
mine from the OP-Shop/Secondhand Shop for 50¢ ea.
 

Texy

Senior Member
As promised, here is code that is working on my 18x axe090 pcb. The 'typo' quoted by Westaust55 earlier, was simply where I cut n pasted it and the single line of code overlapped to another when I pasted it:rolleyes:
This is my enhanced code with character-set programmed into
the 18x's eeprom area.

Code:
; Nokia LCD driver
#picaxe 18x
 
symbol SCLK = 0 'Display pin 2 to PICAXE out 0
symbol SDA = 5 'Display pin 3 to PICAXE out 5
symbol DC = 2 'Display pin 4 to PICAXE out 2
symbol CS = 3 'Display pin 5 to PICAXE out 3
symbol RES = 6 'Display pin 8 to PICAXE out 6
symbol Value = b0
symbol X = b3
symbol Y = b4
symbol eeprom_address = b5
symbol Loop1 = b10
symbol loop3 = b12
SYMBOL SDA_PIN = outpin5
 
setfreq m8
gosub InitLCD
Value="H"
gosub CharToLCD
Value="I"
gosub CharToLCD
Value=" "
gosub CharToLCD
Value="P"
gosub CharToLCD
Value="I"
gosub CharToLCD
Value="C"
gosub CharToLCD
Value="A"
gosub CharToLCD
Value="X"
gosub CharToLCD
Value="E"
gosub CharToLCD
Value=" "
gosub CharToLCD
Value="F"
gosub CharToLCD
Value="O"
gosub CharToLCD
Value="R"
gosub CharToLCD
Value="U"
gosub CharToLCD
Value="M"
gosub CharToLCD
Value="!"
gosub CharToLCD
GoSub Invert
pause 50
GoSub Normal
setfreq m4
Stop
End
InitLCD:
low SCLK
low SDA
low DC
low CS
low RES
pause 50
high RES
high CS
;Command = 1
Value=$21
gosub CommandToLCD ` transmit to serial LCD module
Value=$C9
gosub CommandToLCD ` transmit to serial LCD module
Value=$13
gosub CommandToLCD ` transmit to serial LCD module
Value=$20
gosub CommandToLCD ` transmit to serial LCD module
Value=$09
gosub CommandToLCD ` transmit to serial LCD module
Value=$08
gosub CommandToLCD ` transmit to serial LCD module
X = 0
Y = 0
GoSub GotoXY
GoSub ClearFast
GoSub Normal
return
CharToLCD:
eeprom_address=0
if Value>32 and Value <58 then
eeprom_address=Value-33
eeprom_address=eeprom_address*5+130
elseif Value>64 and Value <91 then
eeprom_address=Value-65
eeprom_address=eeprom_address*5
elseif Value=32 then
Value=0
gosub DataToLCD
gosub DataToLCD
gosub DataToLCD
gosub DataToLCD
gosub DataToLCD
end if
if Value=0 then
return
end if
For Loop1 = 0 To 4
read eeprom_address, Value
inc eeprom_address
GoSub DataToLCD
Next Loop1
Return
CommandToLCD:
low DC 'Command mode
DataMode1:
low CS
SDA_PIN = bit7
PulsOut SCLK,1
SDA_PIN = bit6
PulsOut SCLK,1
SDA_PIN = bit5
PulsOut SCLK,1
SDA_PIN = bit4
PulsOut SCLK,1
SDA_PIN = bit3
PulsOut SCLK,1
SDA_PIN = bit2
PulsOut SCLK,1
SDA_PIN = bit1
PulsOut SCLK,1
SDA_PIN = bit0
PulsOut SCLK,1
high CS
Return
DataToLCD:
high DC 'Data mode
DataMode2:
low CS
SDA_PIN = bit7
PulsOut SCLK,1
SDA_PIN = bit6
PulsOut SCLK,1
SDA_PIN = bit5
PulsOut SCLK,1
SDA_PIN = bit4
PulsOut SCLK,1
SDA_PIN = bit3
PulsOut SCLK,1
SDA_PIN = bit2
PulsOut SCLK,1
SDA_PIN = bit1
PulsOut SCLK,1
SDA_PIN = bit0
PulsOut SCLK,1
high CS
Return
ClearFast:
low SDA
high DC
low CS
For Loop1 = 1 To 48
For loop3 = 1 To 84
low SCLK
high SCLK
Next loop3
Next Loop1
Return
GotoXY:
;Command = 1
Value = X + 128
GoSub CommandToLCD
Value = Y + 64
GoSub CommandToLCD
Return
Invert:
;Command = 1
Value = 13
GoSub CommandToLCD
Return
 
Normal:
Value = 12
GoSub CommandToLCD
Return
 
eeprom 0,(0x7E, 0x11, 0x11, 0x11, 0x7E) ; A
eeprom (0x7F, 0x49, 0x49, 0x49, 0x36) ; B
eeprom (0x3E, 0x41, 0x41, 0x41, 0x22) ; C
eeprom (0x7F, 0x41, 0x41, 0x22, 0x1C) ; D
eeprom (0x7F, 0x49, 0x49, 0x49, 0x41) ; E
eeprom (0x7F, 0x09, 0x09, 0x09, 0x01) ; F
eeprom (0x3E, 0x41, 0x49, 0x49, 0x7A) ; G
eeprom (0x7F, 0x08, 0x08, 0x08, 0x7F) ; H
eeprom (0x00, 0x41, 0x7F, 0x41, 0x00) ; I
eeprom (0x20, 0x40, 0x41, 0x3F, 0x01) ; J
eeprom (0x7F, 0x08, 0x14, 0x22, 0x41) ; K
eeprom (0x7F, 0x40, 0x40, 0x40, 0x40) ; L
eeprom (0x7F, 0x02, 0x0C, 0x02, 0x7F) ; M
eeprom (0x7F, 0x04, 0x08, 0x10, 0x7F) ; N
eeprom (0x3E, 0x41, 0x41, 0x41, 0x3E) ; O
eeprom (0x7F, 0x09, 0x09, 0x09, 0x06) ; P
eeprom (0x3E, 0x41, 0x51, 0x21, 0x5E) ; Q
eeprom (0x7F, 0x09, 0x19, 0x29, 0x46) ; R
eeprom (0x46, 0x49, 0x49, 0x49, 0x31) ; S
eeprom (0x01, 0x01, 0x7F, 0x01, 0x01) ; T
eeprom (0x3F, 0x40, 0x40, 0x40, 0x3F) ; U
eeprom (0x1F, 0x20, 0x40, 0x20, 0x1F) ; V
eeprom (0x3F, 0x40, 0x38, 0x40, 0x3F) ; W
eeprom (0x63, 0x14, 0x08, 0x14, 0x63) ; X
eeprom (0x07, 0x08, 0x70, 0x08, 0x07) ; Y
eeprom (0x61, 0x51, 0x49, 0x45, 0x43) ; Z
eeprom (0x00, 0x00, 0x2f, 0x00, 0x00) ; !
eeprom (0x00, 0x07, 0x00, 0x07, 0x00) ; "
eeprom (0x14, 0x7f, 0x14, 0x7f, 0x14) ; #
eeprom (0x24, 0x2a, 0x7f, 0x2a, 0x12) ; $
eeprom (0xc4, 0xc8, 0x10, 0x26, 0x46) ; %
eeprom (0x36, 0x49, 0x55, 0x22, 0x50) ; &
eeprom (0x00, 0x05, 0x03, 0x00, 0x00) ; '
eeprom (0x00, 0x1c, 0x22, 0x41, 0x00) ; (
eeprom (0x00, 0x41, 0x22, 0x1c, 0x00) ; )
eeprom (0x14, 0x08, 0x3E, 0x08, 0x14) ; *
eeprom (0x08, 0x08, 0x3E, 0x08, 0x08) ; +
eeprom (0x00, 0x00, 0x50, 0x30, 0x00) ; ,
eeprom (0x10, 0x10, 0x10, 0x10, 0x10) ; -
eeprom (0x00, 0x60, 0x60, 0x00, 0x00) ; .
eeprom (0x20, 0x10, 0x08, 0x04, 0x02) ; /
eeprom (0x3E, 0x51, 0x49, 0x45, 0x3E) ; 0
eeprom (0x00, 0x42, 0x7F, 0x40, 0x00) ; 1
eeprom (0x42, 0x61, 0x51, 0x49, 0x46) ; 2
eeprom (0x21, 0x41, 0x45, 0x4B, 0x31) ; 3
eeprom (0x18, 0x14, 0x12, 0x7F, 0x10) ; 4
eeprom (0x27, 0x45, 0x45, 0x45, 0x39) ; 5
eeprom (0x3C, 0x4A, 0x49, 0x49, 0x30) ; 6
eeprom (0x01, 0x71, 0x09, 0x05, 0x03) ; 7
eeprom (0x36, 0x49, 0x49, 0x49, 0x36) ; 8
eeprom (0x06, 0x49, 0x49, 0x29, 0x1E) ; 9
..and a pic taken with my iPhone of what is displayed :



Hope this helps,
Texy
 
Last edited:

eclectic

Moderator
Thanks for the code Texy.

May I bug you with more questions please?

1. Have you connected the Nokia directly to V+ and to the Picaxe outputs?

2. Is there a capacitor between nokia pins 7 - 6, and if so, of what value?

3. In your program, at lines 54 and 84, there is "gosub Normal"

Should "normal:" be inserted at line 178?

e
 
Last edited:

Texy

Senior Member
Thanks for the code Texy.

May I bug you with more questions please?

1. Have you connected the Nokia directly to V+ and to the Picaxe outputs?

2. Is there a capacitor between nokia pins 7 - 6, and if so, of what value?

3. In your program, at lines 54 and 84, there is "gosub Normal"

Should "normal:" be inserted at line 178?

e
1.Yes - no series resistors either. The battery pack has gone from +5.5v down to 2.5volts and still working:eek:
2.Yes - 10uF - I don't know if the value is critial, but when I first started play with the lcd, I didn't have one fitted at all - result : no output.
3. My bad - I deleted some rem comments before posting and deleted that line by mistake - I,ve now editted it back in to the post.

HTH
Texy
 

Mycroft2152

Senior Member
Texy,

Nicely done! I've got a few of the displays in my "junk" drawer that have been waiting for a program.

Definiely a link that goes into my PICAXE grimoire.

Myc
 

westaust55

Moderator
Texy,

Good to see that yours is going well.

I note that you have adjusted the Vlcd up to 7.44Volts. Not a large increase over past code (so up about 0.12 Volts).

Did you find this was neceesary to give a "brighter display.

Are there any backlight terminals on the 3310 LCD module.

Info I found yesterday suggested (as an option may be) two plated through holes one either side near the bottom corners at the rear when a backlight exists.

Electic,
Hope you get yours operational today.

Might have to look out for one for my experimenting pleasure as well. :D
 
Last edited:

Texy

Senior Member
I just used the same values I found in previous code examples. Playing around with different values doesn't seem to be having a great effect:confused:
Yes, my lcd has backlight connections, which I haven't played around with yet.

Cheers,
Texy
 

eclectic

Moderator
Thrice woe!

I just used the same values I found in previous code examples. Playing around with different values doesn't seem to be having a great effect:confused:
Yes, my lcd has backlight connections, which I haven't played around with yet.

Cheers,
Texy
I've tried three separate displays and still no go.

Possibilities:
1. My ineptitude in circuit building.
2. The displays I've bought are "non-standard".

Mine haven't got backlight connections. Hmm?

Texy, can I please ask,
where did you buy your working display from?

e.
 

Texy

Senior Member
Actually, the I bought off ebay I haven't tried yet. The one I am using has been pulled out of a 3310. I,d be happy to try one of your ones if you send it to me.

Texy
 

eclectic

Moderator
Fourth time - partially lucky.

I've just tried the fourth of the "Nokia" modules.

I used the code from post #1 in this thread.

http://homepage.ntlworld.com/c.lewis19/nokia.htm

2 x 4.7 uF (//) between lines 6-7.

And, very importantly, the 28X1 powered by two new Duracell AA.

It works!. Been flashing away for ~30 minutes.

I can only assume that the other LCD's were zapped by the 4.5 - 4.9 voltages,
either on V+ or Picaxe pins 0 -4.
I've tried them with the 3 volt setup. SFA!

Now, with the info. provided by WestAus and Texy, I can perhaps proceed.
I'm happy to have paid £3 for the lesson, and, more importantly,
perhaps provided a minor warning for others:
Use 3 volts to start with!

Thanks both.
 
Last edited:

westaust55

Moderator
Great to hear that you have had success eclectic.

With regard to the backlight, a little more close reading reveals the LED’s for this are mounted on the PCB to which the LCD module is normally clipped. Therefore if you only have the basic LCD without the old PCD there will be no backlight. But as they are external LED’s mounted 3 per side along the rear of the side edges of the LCD module you may be able to set up your own backlight.

Noting that you have a 28X1, you should be able to use the SHIFTOUT command to transfer data to the LCD rather than bit-bashing the data through one bit at a time. I have done this with a 74HC595 shift register attached to my 40X1 and it worked. Some checks on speed suggested up to 7 times faster using the SHIFTOUT command.

in the subroutine WriteToLCD:


In place of the FOR Loop2 = 1 to 8 . . . . NEXT Loop2
try:


SHIFTOUT SCLK, SDA, MSBFIRST_L, (Value / 8)


Had a look on Ebay (Aust and US) last night and no examples of the 3310 LCD module alone for sale right now.
Here in Aust a few complete 3310’s for sale but at around AUD$20 each, will hold off for now.

Good point with respect to voltages possibly stuffing up a few LCD modules.
A simple series resistor will not limit the voltage to the LCD. I think use of a voltage divider might be in order. 560 Ohm in series with 1200 Ohm seems a good compromise.
 

Attachments

Texy

Senior Member
Great stuff!
I,ll be needing 5volts for the mpx4115 in my altimeter, so I guess I was just lucky with my lcd. Now that you got the code and hardware to a known working state, are you going to re-try your other panels?
Texy
 

Texy

Senior Member
Great to hear that you have had success eclectic.
Had a look on Ebay (Aust and US) last night and no examples of the 3310 LCD module alone for sale right now.
Here in Aust a few complete 3310’s for sale but at around AUD$20 each, will hold off for now.
.
...but there is in ebay aust stores :

http://cgi.ebay.com.au/New-High-Quality-Nokia-3310-3315-3330-LCD-Screen_W0QQitemZ160207940288QQihZ006QQcategoryZ150767QQrdZ1QQssPageNameZWD1VQQcmdZViewItemQQ_trksidZp1638Q2em118Q2el1247


Texy
 

eclectic

Moderator
Texy.

I've tried them with the 3 volt setup. SFA! :(
Hmm? I wonder if the mini-speakers are worth hacking?
(Resistance ~30 ohms)

But, at less than a quid each, I've learnt some valuable lessons.
Thanks again.
e
 

westaust55

Moderator
Thanks Texy,

but those three are actually in HCM City in Vietnam and AUD$8 each for screen and AUD$10 for postage each (whatever "but not all of them, please contact us to verify about this" means wrt combined postage).

Have spied one here in Aust for AUD$1 but . . . . AUD$15 postage.

Thinks I will hold till I see something for a more respectable parts/secondhand price.

EDIT:
This one from Hong Kong for AUD$9 and AUD$2-85 for postage (seller has 21 of these) - pric is getting better :)
http://cgi.ebay.com.au/I129-LCD-Screen-Display-for-Nokia-3310-3315-3330_W0QQitemZ260163840272QQihZ016QQcategoryZ150767QQrdZ1QQssPageNameZWD1VQQcmdZViewItemQQ_trksidZp1638Q2em118Q2el1247
===============
 
Last edited:

westaust55

Moderator
Thanks e,

thats looking much better. :)
While about AUD$11.20 for one, down to $6.36ea for two or $4ea spread over 4.

See he's away for next 10 days but will go for it on his return (unless even better pricing found in the next week).
 

eclectic

Moderator
More playing.

@Texy
Around line 20 of your program, there is a list of

Value="E"
gosub CharToLCD

type lines.

I've just tried this, on a 28X1

Code:
setfreq m8
gosub InitLCD

for b20 = 0 to 100 '**** can be shortened to save time
lookup b20,(" THIS CAN SAVE    LOTS OF MEMORY   AND TYPING.  ") ,b21
Value=b21
gosub CharToLCD
next b20
Just make sure that the last character in the "string" is a blank space.

Obviously, b20, b21 don't exist on an 18X, but,
with a bit of jiggery pokery, .....

e
 

Attachments

Last edited:

hippy

Technical Support
Staff member
Well done everyone. I've got some Nokia phones I was going to strip the LCD's out of but was waiting for others to get the code working :)

Now we have a solution two things would be very useful -

1) A posting of the code which works - I don't mind putting some effort into minimising it's footprint and optimising. Posting to Finished Projects Audio-Visual is what I'd suggest.

2) Someone with a working setup to run the PICAXE and LCD from a bench PSU and determine what voltage ranges it works with.

It would also be nice but not essential if someone with some electronic experience and a willingness to potentially sacrifice a display could get one working with a 7805 5V PICAXE if that's possible. Especially if that can be done without needing a 3V3 LDO for display power - a voltage divider as suggested earlier or a simple zener supply.
 

eclectic

Moderator
Well done everyone. I've got some Nokia phones I was going to strip the LCD's out of but was waiting for others to get the code working :)

Now we have a solution two things would be very useful -

1) A posting of the code which works - I don't mind putting some effort into minimising it's footprint and optimising. Posting to Finished Projects Audio-Visual is what I'd suggest.

2) Someone with a working setup to run the PICAXE and LCD from a bench PSU and determine what voltage ranges it works with.

It would also be nice but not essential if someone with some electronic experience and a willingness to potentially sacrifice a display could get one working with a 7805 5V PICAXE if that's possible. Especially if that can be done without needing a 3V3 LDO for display power - a voltage divider as suggested earlier or a simple zener supply.
1. I've done some very rough surgery on the program.
"Working" code below.
But I wouldn't dream of posting in "Finished Projects"!

2. / 3. I've ordered some more displays and I'll be happy to test, when they arrive.
(10 days to wait though).
At the moment, the one survivor is on a strict 3 volt diet.
Obviously, there are different models on the market.
e

Code:
; Nokia LCD driver
'modified Tue 01 07 08, from Texy's original code
'
#picaxe 28x1
 
symbol SCLK = 0 'Display pin 2 to PICAXE out 0
symbol SDA = 1 'Display pin 3 to PICAXE out 5
symbol DC = 2 'Display pin 4 to PICAXE out 2
symbol CS = 3 'Display pin 5 to PICAXE out 3
symbol RES = 4 'Display pin 8 to PICAXE out 6
symbol Value = b0
symbol X = b3
symbol Y = b4
symbol eeprom_address = b5
symbol Loop1 = b10
symbol loop3 = b12
SYMBOL SDA_PIN = outpin1 'outpin5 ************
 
 
setfreq m8  ' or em16 is even better!
gosub InitLCD
b20="#" ' use another character if required
lookdown b20,(" THIS CAN SAVE    LOTS OF MEMORY   AND TYPING. # "),b21
b23 = b21
for b20 = 0 to b23 '****
lookup b20,(" THIS CAN SAVE    LOTS OF MEMORY   AND TYPING.  ") ,b23
Value=b23
gosub CharToLCD
next b20

for b20 = 0 to 25 '****
lookup b20,("  ANOTHER TEST     LINE.  ") ,b21
Value=b21
gosub CharToLCD
next b20


'GoSub Invert **********

'GoSub Normal ************
setfreq m4

End

InitLCD:
low SCLK
low SDA
low DC
low CS
low RES
pause 50
high RES
high CS

Value=$21
gosub CommandToLCD ` transmit to serial LCD module
Value=$C9
gosub CommandToLCD ` transmit to serial LCD module
Value=$13
gosub CommandToLCD ` transmit to serial LCD module
Value=$20
gosub CommandToLCD ` transmit to serial LCD module
Value=$09
gosub CommandToLCD ` transmit to serial LCD module
Value=$08
gosub CommandToLCD ` transmit to serial LCD module
X = 0
Y = 0
GoSub GotoXY
;GoSub ClearFast ******** REMOVED
GoSub Normal
return

CharToLCD:
eeprom_address=0
if Value>32 and Value <58 then
eeprom_address=Value-33
eeprom_address=eeprom_address*5+130
elseif Value>64 and Value <91 then
eeprom_address=Value-65
eeprom_address=eeprom_address*5
elseif Value=32 then
Value=0
gosub DataToLCD
gosub DataToLCD
gosub DataToLCD
gosub DataToLCD
gosub DataToLCD
end if
if Value=0 then
return
end if
For Loop1 = 0 To 4
read eeprom_address, Value
inc eeprom_address
GoSub DataToLCD
Next Loop1
Return
CommandToLCD:
low DC 'Command mode
DataMode1:
low CS


SDA_PIN = bit7
PulsOut SCLK,1
SDA_PIN = bit6
PulsOut SCLK,1
SDA_PIN = bit5
PulsOut SCLK,1
SDA_PIN = bit4
PulsOut SCLK,1
SDA_PIN = bit3
PulsOut SCLK,1
SDA_PIN = bit2
PulsOut SCLK,1
SDA_PIN = bit1
PulsOut SCLK,1
SDA_PIN = bit0
PulsOut SCLK,1
high CS
Return
DataToLCD:
high DC 'Data mode
DataMode2:
low CS
SDA_PIN = bit7
PulsOut SCLK,1
SDA_PIN = bit6
PulsOut SCLK,1
SDA_PIN = bit5
PulsOut SCLK,1
SDA_PIN = bit4
PulsOut SCLK,1
SDA_PIN = bit3
PulsOut SCLK,1
SDA_PIN = bit2
PulsOut SCLK,1
SDA_PIN = bit1
PulsOut SCLK,1
SDA_PIN = bit0
PulsOut SCLK,1
high CS
Return
#REM **********REMOVED 
ClearFast:
low SDA
high DC
low CS
For Loop1 = 1 To 48
For loop3 = 1 To 84
'low SCLK *********************
pulsout SCLK ,1 'high SCLK
Next loop3
Next Loop1
Return
#ENDREM *** REMOVED

GotoXY:

Value = X + 128
GoSub CommandToLCD
Value = Y + 64
GoSub CommandToLCD
Return
Invert:

Value = 13
GoSub CommandToLCD
Return
 
Normal:
Value = 12
GoSub CommandToLCD
Return
 
eeprom 0,(0x7E, 0x11, 0x11, 0x11, 0x7E) ; A
eeprom (0x7F, 0x49, 0x49, 0x49, 0x36) ; B
eeprom (0x3E, 0x41, 0x41, 0x41, 0x22) ; C
eeprom (0x7F, 0x41, 0x41, 0x22, 0x1C) ; D
eeprom (0x7F, 0x49, 0x49, 0x49, 0x41) ; E
eeprom (0x7F, 0x09, 0x09, 0x09, 0x01) ; F
eeprom (0x3E, 0x41, 0x49, 0x49, 0x7A) ; G
eeprom (0x7F, 0x08, 0x08, 0x08, 0x7F) ; H
eeprom (0x00, 0x41, 0x7F, 0x41, 0x00) ; I
eeprom (0x20, 0x40, 0x41, 0x3F, 0x01) ; J
eeprom (0x7F, 0x08, 0x14, 0x22, 0x41) ; K
eeprom (0x7F, 0x40, 0x40, 0x40, 0x40) ; L
eeprom (0x7F, 0x02, 0x0C, 0x02, 0x7F) ; M
eeprom (0x7F, 0x04, 0x08, 0x10, 0x7F) ; N
eeprom (0x3E, 0x41, 0x41, 0x41, 0x3E) ; O
eeprom (0x7F, 0x09, 0x09, 0x09, 0x06) ; P
eeprom (0x3E, 0x41, 0x51, 0x21, 0x5E) ; Q
eeprom (0x7F, 0x09, 0x19, 0x29, 0x46) ; R
eeprom (0x46, 0x49, 0x49, 0x49, 0x31) ; S
eeprom (0x01, 0x01, 0x7F, 0x01, 0x01) ; T
eeprom (0x3F, 0x40, 0x40, 0x40, 0x3F) ; U
eeprom (0x1F, 0x20, 0x40, 0x20, 0x1F) ; V
eeprom (0x3F, 0x40, 0x38, 0x40, 0x3F) ; W
eeprom (0x63, 0x14, 0x08, 0x14, 0x63) ; X
eeprom (0x07, 0x08, 0x70, 0x08, 0x07) ; Y
eeprom (0x61, 0x51, 0x49, 0x45, 0x43) ; Z
eeprom (0x00, 0x00, 0x2f, 0x00, 0x00) ; !
eeprom (0x00, 0x07, 0x00, 0x07, 0x00) ; "
eeprom (0x14, 0x7f, 0x14, 0x7f, 0x14) ; #
eeprom (0x24, 0x2a, 0x7f, 0x2a, 0x12) ; $
eeprom (0xc4, 0xc8, 0x10, 0x26, 0x46) ; %
eeprom (0x36, 0x49, 0x55, 0x22, 0x50) ; &
eeprom (0x00, 0x05, 0x03, 0x00, 0x00) ; '
eeprom (0x00, 0x1c, 0x22, 0x41, 0x00) ; (
eeprom (0x00, 0x41, 0x22, 0x1c, 0x00) ; )
eeprom (0x14, 0x08, 0x3E, 0x08, 0x14) ; *
eeprom (0x08, 0x08, 0x3E, 0x08, 0x08) ; +
eeprom (0x00, 0x00, 0x50, 0x30, 0x00) ; ,
eeprom (0x10, 0x10, 0x10, 0x10, 0x10) ; -
eeprom (0x00, 0x60, 0x60, 0x00, 0x00) ; .
eeprom (0x20, 0x10, 0x08, 0x04, 0x02) ; /
eeprom (0x3E, 0x51, 0x49, 0x45, 0x3E) ; 0
eeprom (0x00, 0x42, 0x7F, 0x40, 0x00) ; 1
eeprom (0x42, 0x61, 0x51, 0x49, 0x46) ; 2
eeprom (0x21, 0x41, 0x45, 0x4B, 0x31) ; 3
eeprom (0x18, 0x14, 0x12, 0x7F, 0x10) ; 4
eeprom (0x27, 0x45, 0x45, 0x45, 0x39) ; 5
eeprom (0x3C, 0x4A, 0x49, 0x49, 0x30) ; 6
eeprom (0x01, 0x71, 0x09, 0x05, 0x03) ; 7
eeprom (0x36, 0x49, 0x49, 0x49, 0x36) ; 8
eeprom (0x06, 0x49, 0x49, 0x29, 0x1E) ; 9
 
Last edited:

Texy

Senior Member
@Texy
Around line 20 of your program, there is a list of

Value="E"
gosub CharToLCD

type lines.

I've just tried this, on a 28X1

Code:
setfreq m8
gosub InitLCD
 
for b20 = 0 to 100 '**** can be shortened to save time
lookup b20,(" THIS CAN SAVE    LOTS OF MEMORY   AND TYPING.  ") ,b21
Value=b21
gosub CharToLCD
next b20
Just make sure that the last character in the "string" is a blank space.

Obviously, b20, b21 don't exist on an 18X, but,
with a bit of jiggery pokery, .....

e
Magic!
With every bit of code introduced to me I,m learning new commands - Lookup is a new one to me, so thanks. Thats a great way to introduce strings to the code library;)

Hippy - we have working code in this thread. I think it's gonna be best to keep with the 3-3.5 volt range. Although my display seemed to be working at as high as 5.5v, I did notice that it would glitch quite badly (display suddenly blanking for no apparent reason). Since my 4 AA cell battery pack's voltage has been creaping down use use, it has remained very stable - current voltage 3.5 volts.
Slightly off topic, but connected to the voltage drop on my battery pack. I wasted my lunchtime today over a problem with the DS1307 timekeeper in my circuit. I have permanently soldered a crystal and backup button-cell to the legs to ease dev work. This lunchtime it was reading $FF for all values. As a besides, I have received some free sample requests from Maxim, including a couple of DS1307's, which also didn't seem to work. I then realised that the supply rail had crept down, and the voltage requirements for the chip are 4.5 - 5.5volts, doh:rolleyes:

Texy
 

westaust55

Moderator
Texy,

I have changed out my DS1307 RTC's to DS1338 RTC's.
Needs an adapter to hold the surface mount chip but there are several solutions used by myself and BCJKiwi for example (search other threads).

The DS1338 is pin for pin compatible, programwise it's identical for registers and even the 56 bytes of NV RAM. And the nominal 3.3V version (DS1338Z-33) operates over the rated voltage range 3.0V to 5.5V.
And finally, it is 400kHz rated so usable with i2cfast commands.
 

Texy

Senior Member
Interesting! There's also a version with built in xtal. Shame there's no DIL part tho:rolleyes:
Looks like I,ll need to order some more samples:D
Texy
 

hippy

Technical Support
Staff member
A first attempt untested optimisation saves 40% code space getting from 547 bytes to 328. Needs work doing on the Eeprom plus character to Eeprom mapping which will add some overhead as only supports space, 0-9, A-Z and a-z so far.

Code:
; Nokia LCD driver
; Modified Tue 01 07 08, from Texy's original code
; Modified Tue 2008-07-01 by Hippy ( Untested )

#picaxe 28x1
 
Symbol SCLK    = 0 ' Display pin 2 to PICAXE out 0
Symbol SDA     = 1 ' Display pin 3 to PICAXE out 5
Symbol DC      = 2 ' Display pin 4 to PICAXE out 2
Symbol CS      = 3 ' Display pin 5 to PICAXE out 3
Symbol RES     = 4 ' Display pin 8 to PICAXE out 6

Symbol SDA_PIN = outpin1

Symbol value   = b0
Symbol X       = b0
Symbol Y       = b1
Symbol XY      = w0
Symbol eepAdr  = b1
 
SetFreq M8 ' or EM16 is even better!

Gosub InitLCD

b1 = 0
Do
  LookUp b1,(" THIS CAN SAVE    LOTS OF MEMORY   AND TYPING.",0),value
  Gosub LookUpCharToLCD
Loop Until value = 0

For b1 = 0 To 25
  LookUp b1,("  ANOTHER TEST     LINE.  "),value
  Gosub CharToLCD
Next

End

InitLCD:
  pins = 0
  Pause 50
  High RES
  High CS
  For eepAdr = 0 To 5
    Read eepAdr, value
    Gosub CommandToLCD
  Next
  Gosub Normal
  
GotoHome:
  XY = 0

GotoXY:
  value = X + 128
  GoSub CommandToLCD
  value = Y + 64

CommandToLcd:
  low DC
  goto B0ToLcd

Invert:
  value = 13
  Goto CommandToLcd
 
Normal:
  value = 12
  Goto CommandToLcd

LookUpCharToLcd:
  If value = 0 Then BaleOut
  b1 = b1+1
    
CharToLcd:
  value = value Min $20
  eepAdr = 1
  If value >= "A" Then
    bit6 = 1
    bit5 = 0
    eepAdr = value - "A" + 2
  Else
    If value >= "0" Then
      eepAdr = value - "0" + 28
    End If
  End If
  eepAdr = eepAdr * 5

  High DC
        
  Gosub EepromToLcd
  Gosub EepromToLcd
  Gosub EepromToLcd
  Gosub EepromToLcd

EepromToLcd:

  Read eepAdr, b0
  eepAdr = eepAdr+1
  
B0ToLcd:
  Low CS
  SDA_PIN = bit7 : PulsOut SCLK,1
  SDA_PIN = bit6 : PulsOut SCLK,1
  SDA_PIN = bit5 : PulsOut SCLK,1
  SDA_PIN = bit4 : PulsOut SCLK,1
  SDA_PIN = bit3 : PulsOut SCLK,1
  SDA_PIN = bit2 : PulsOut SCLK,1
  SDA_PIN = bit1 : PulsOut SCLK,1
  SDA_PIN = bit0 : PulsOut SCLK,1
  High CS
BaleOut:
  Return
 
eeprom ($21,$C9,$13,$20,$09,$08)

eeprom (0x00, 0x00, 0x00, 0x00, 0x00) ; Space


eeprom (0x7E, 0x11, 0x11, 0x11, 0x7E) ; A
eeprom (0x7F, 0x49, 0x49, 0x49, 0x36) ; B
eeprom (0x3E, 0x41, 0x41, 0x41, 0x22) ; C
eeprom (0x7F, 0x41, 0x41, 0x22, 0x1C) ; D
eeprom (0x7F, 0x49, 0x49, 0x49, 0x41) ; E
eeprom (0x7F, 0x09, 0x09, 0x09, 0x01) ; F
eeprom (0x3E, 0x41, 0x49, 0x49, 0x7A) ; G
eeprom (0x7F, 0x08, 0x08, 0x08, 0x7F) ; H
eeprom (0x00, 0x41, 0x7F, 0x41, 0x00) ; I
eeprom (0x20, 0x40, 0x41, 0x3F, 0x01) ; J
eeprom (0x7F, 0x08, 0x14, 0x22, 0x41) ; K
eeprom (0x7F, 0x40, 0x40, 0x40, 0x40) ; L
eeprom (0x7F, 0x02, 0x0C, 0x02, 0x7F) ; M
eeprom (0x7F, 0x04, 0x08, 0x10, 0x7F) ; N
eeprom (0x3E, 0x41, 0x41, 0x41, 0x3E) ; O
eeprom (0x7F, 0x09, 0x09, 0x09, 0x06) ; P
eeprom (0x3E, 0x41, 0x51, 0x21, 0x5E) ; Q
eeprom (0x7F, 0x09, 0x19, 0x29, 0x46) ; R
eeprom (0x46, 0x49, 0x49, 0x49, 0x31) ; S
eeprom (0x01, 0x01, 0x7F, 0x01, 0x01) ; T
eeprom (0x3F, 0x40, 0x40, 0x40, 0x3F) ; U
eeprom (0x1F, 0x20, 0x40, 0x20, 0x1F) ; V
eeprom (0x3F, 0x40, 0x38, 0x40, 0x3F) ; W
eeprom (0x63, 0x14, 0x08, 0x14, 0x63) ; X
eeprom (0x07, 0x08, 0x70, 0x08, 0x07) ; Y
eeprom (0x61, 0x51, 0x49, 0x45, 0x43) ; Z

eeprom (0x3E, 0x51, 0x49, 0x45, 0x3E) ; 0
eeprom (0x00, 0x42, 0x7F, 0x40, 0x00) ; 1
eeprom (0x42, 0x61, 0x51, 0x49, 0x46) ; 2
eeprom (0x21, 0x41, 0x45, 0x4B, 0x31) ; 3
eeprom (0x18, 0x14, 0x12, 0x7F, 0x10) ; 4
eeprom (0x27, 0x45, 0x45, 0x45, 0x39) ; 5
eeprom (0x3C, 0x4A, 0x49, 0x49, 0x30) ; 6
eeprom (0x01, 0x71, 0x09, 0x05, 0x03) ; 7
eeprom (0x36, 0x49, 0x49, 0x49, 0x36) ; 8
eeprom (0x06, 0x49, 0x49, 0x29, 0x1E) ; 9

'eeprom (0x00, 0x00, 0x2f, 0x00, 0x00) ; !
'eeprom (0x14, 0x7f, 0x14, 0x7f, 0x14) ; #
'eeprom (0x24, 0x2a, 0x7f, 0x2a, 0x12) ; $
'eeprom (0xc4, 0xc8, 0x10, 0x26, 0x46) ; %
'eeprom (0x36, 0x49, 0x55, 0x22, 0x50) ; &
'eeprom (0x00, 0x05, 0x03, 0x00, 0x00) ; '
'eeprom (0x00, 0x1c, 0x22, 0x41, 0x00) ; (
'eeprom (0x00, 0x41, 0x22, 0x1c, 0x00) ; )
'eeprom (0x14, 0x08, 0x3E, 0x08, 0x14) ; *
'eeprom (0x08, 0x08, 0x3E, 0x08, 0x08) ; +
'eeprom (0x00, 0x00, 0x50, 0x30, 0x00) ; ,
'eeprom (0x10, 0x10, 0x10, 0x10, 0x10) ; -
'eeprom (0x00, 0x60, 0x60, 0x00, 0x00) ; .
'eeprom (0x20, 0x10, 0x08, 0x04, 0x02) ; /
 

westaust55

Moderator
The primary difference is that the Nokia 3310 (and Siemens A55) LCD displays as have been covered in this and another thread to date are Black and White displays with a relatively low resolution.

That Instructables project is based upon the Nokia 6100 (and similar) Colour LCD displays.

there are apaprently from my past reading, two controllers used for this display and Sparkfun use a "knock off" version and all ahve some variances. Thus care is needed in making sure you know which "Nokia" colour LCD and more specifically which controller chip you are using.
 
Top