⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3510i_for_mega128l.bas

📁 NOKIA手机液晶屏I3510的应用例程
💻 BAS
字号:
'Ansteuerung eines Nokia 3510i Farb-Display
'Copyright Martin Kuehn    Januar 2004
'martin-k@x-mail.net
'Dieses Programm dient nur f黵 Demonstrationszwecke und ist absichtlich
'sehr einfach gehalten. Es ging mir nicht darum, elegant zu programmieren,
'sondern exemplarisch die Display-Ansteuerung aufzuzeigen.
'Prozessor: AVR Mega128, 3 Volt, Taktfrequenz 4 MHz
'Viele Werte zur Ansteuerung sind willk黵lich gew鋒lt und k鰊nen noch
'optimiert werden.
'Bei einer Taktfrequenz von 黚er 8 MHz k鰊nte die Ansteuerung des Displays
'nicht mehr funktionieren, eventuell Wait-Befehle einf黦en
'Es scheint so, dass die LCD-Spannung durch Software nicht ver鋘dert werden
'kann, dementsprechend kann auch der Kontrast nicht ver鋘dert werden.
'Ich habe bei meinem Display einen Kondensator zwischen Vlcd (Pin 8) und
'GND geschaltet um das Flimmern zu verhindern.

'Controller D15G14E_14_030526


'Display Pin 1 Reset => AVR Pin A0
'            2 CS               A1
'            3 GND              GND
'            4 Sdata            A2
'            5 Sclk             A3
'            6 Vdigital         Vdd (3 Volt)
'            7 Vbooster         Vdd
'            8 Vlcd

Ddra = &B11111111       'Port A als Output
Dim A As Byte , B As Byte , R As Integer , S As Byte

'Initialisierung Reset
Porta.0 = 0
Waitms 5
Porta.0 = 1


Porta.1 = 1
Porta.2 = 1
Porta.3 = 1


'Software Reset
A = &H01
Gosub Command
Gosub Cs
Waitms 5

'INIESC
A = &HC6
Gosub Command
Gosub Cs

'***************************************************************************

' <Display setup 1>


'REFSET
A = &B9
Gosub Command
A = 0
Gosub Parameter
Gosub Cs

'Display Control DISCTL
A = &B6
Gosub Command
A = 128
Gosub Parameter       '128 number of clocks, willk黵liche Zahl
A = 128   'no N line inversion (ungerade Zeilenanzahl)
Gosub Parameter
A = 129   '2 divisions in idle mode, bias 1/9
Gosub Parameter
A = 84
Gosub Parameter
A = 69
Gosub Parameter
A = 82
Gosub Parameter
A = 67
Gosub Parameter
Gosub Cs

'Gray Scale Position
'Bei DISCTL wurden 128 clock numbers pro Zeile eingestellt
'Auf diese 128 Cyclen werden die 16 (4 bit) Graustufen verteilt (willk黵lich, Werte m黶sen aber kleiner als 128 sein)
'Die Graustufen gelten f黵 alle Farben
A = &HB3  'GCPSET0
Gosub Command
A = 1
Gosub Parameter
A = 2
Gosub Parameter
A = 4
Gosub Parameter
A = 8
Gosub Parameter
A = 16
Gosub Parameter
A = 30
Gosub Parameter
A = 40
Gosub Parameter
A = 50
Gosub Parameter
A = 60
Gosub Parameter
A = 70
Gosub Parameter
A = 80
Gosub Parameter
A = 90
Gosub Parameter
A = 100
Gosub Parameter
A = 110
Gosub Parameter
A = 127
Gosub Parameter
Gosub Cs

'Gamma curve set
A = &HB5
Gosub Command
A = 1     'GCPSET0
Gosub Parameter
Gosub Cs

'Common driver output select
A = &HBD
Gosub Parameter
A = 0
Gosub Parameter
Gosub Cs



'************************************************************************

' <Power supply setup>


'Power control PWRCTL
A = &HBE
Gosub Command
A = 4     'boosting clock half display clock, internal resistance, high power mode
Gosub Parameter
Gosub Cs

'Sleep out
A = &H11
Gosub Command
Gosub Cs

'Voltage control
Rem A = &BA
Rem Gosub Command
Rem A = 127   'Voltage 127 - 63
Rem Gosub Parameter
Rem A = 3
Rem Gosub Parameter
Rem Gosub Cs


'Contrast
Rem A = &H25
Rem Gosub Command
Rem A = 63    'Voltage
Rem Gosub Parameter
Rem Gosub Cs

'Temperature gradient set
A = &HB7
Gosub Command
A = 0
For R = 1 To 14       'nur erster Wert relevant, restliche 13 Werte auf 0 setzen
Gosub Parameter
Next R
Gosub Cs

'Booster voltage ON
A = &H03
Gosub Command
Gosub Cs


Waitms 40 'Booster voltage stabilizing


'**************************************************************************

' <Display setup2>


'Inversion control
A = &H20  'Off, normal
Gosub Command
Gosub Cs

'andere Einstellung per Reset definiert



'*************************************************************************

' <Display setup3>


'Interface pixel format
'12 bit

'Colour set
'nur f黵 8 bit relevant

'Memory access control
'durch Reset definiert

'Page address set
'durch Reset definiert

'Column address set
'durch Reset defniert

'Memory write
A = &H2C
Gosub Command

'Beipsiel-Routine zeichnet horizontale farbige Balken im 12-bit Modus
'Leider ist die Bascom-Demo-Version speicherlimitiert, daher gr鲞ten
'Teil der Schleifen l鰏chen

S = 0
'roter Balken
For R = 1 To 999
 If S = 0 Then A = 15
 If S = 1 Then A = 240
 If S = 2 Then A = 255
 Gosub Parameter
 S = S + 1
 If S = 3 Then S = 0
Next R


S = 0
'gr黱er Balken
For R = 1 To 999
 If S = 0 Then A = 240
 If S = 1 Then A = 255
 If S = 2 Then A = 15
 Gosub Parameter
 S = S + 1
 If S = 3 Then S = 0
Next R

 S = 0
'blauer Balken
For R = 1 To 999
 If S = 0 Then A = 255
 If S = 1 Then A = 15
 If S = 2 Then A = 240
 Gosub Parameter
 S = S + 1
 If S = 3 Then S = 0
 Next R




S = 0
'gelber Balken
For R = 1 To 999
 If S = 0 Then A = 0
 If S = 1 Then A = 240
 If S = 2 Then A = 15
 Gosub Parameter
 S = S + 1
 If S = 3 Then S = 0
Next R


S = 0
'magenta Balken
For R = 1 To 999
 If S = 0 Then A = 15
 If S = 1 Then A = 0
 If S = 2 Then A = 240
 Gosub Parameter
 S = S + 1
 If S = 3 Then S = 0
Next R

 S = 0
'cyan Balken
For R = 1 To 999
 If S = 0 Then A = 240
 If S = 1 Then A = 15
 If S = 2 Then A = 0
 Gosub Parameter
 S = S + 1
 If S = 3 Then S = 0
 Next R

'wei遝r Balken
A = 0
For R = 1 To 1000
Gosub Parameter
Next R

'schwarzer Balken
A = 255
For R = 1 To 1002
Gosub Parameter
Next R

Gosub Cs

'Display ON
A = &H29
Gosub Command
Gosub Cs



End






'Unterprogramme, Timing der Datenleitungen


'Senden eines Befehls

Command:
Porta.1 = 0       'Cs auf 0  Start der Sequenz

Porta.3 = 0
Porta.2 = 0       '0 f黵 Command
Porta.3 = 1

Porta.3 = 0
B = A And 128
If B = 128 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 64
If B = 64 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 32
If B = 32 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 16
If B = 16 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 8
If B = 8 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 4
If B = 4 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 2
If B = 2 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 1
If B = 1 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Return



'Senden eines Wertes

Parameter:
Porta.1 = 0       'Cs auf 0  Start der Sequenz

Porta.3 = 0
Porta.2 = 1       '1 f黵 Parameter
Porta.3 = 1

Porta.3 = 0
B = A And 128
If B = 128 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 64
If B = 64 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 32
If B = 32 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 16
If B = 16 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 8
If B = 8 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 4
If B = 4 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 2
If B = 2 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Porta.3 = 0
B = A And 1
If B = 1 Then Porta.2 = 1
If B = 0 Then Porta.2 = 0
Porta.3 = 1

Return



Cs:
Porta.1 = 1
Return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -