lcd ansteuerung mit pic16f877

Gast #640189
Lesenswert?

hi,
also ich kriege das lcd nicht initialisiert... es handelt sich um den 
hd44780a00 chip... die timings etc habe ich alle sogar etwas länger 
gemacht jedoch funzt das immer noch nicht... weiss nicht mehr weiter! 
kann mir evtl jemand weiter helfen??
das lcd ist "4 zeilig" mit je 20 zeichen und zeile eins und drei sind 
dunkle balken (kontrast hab ich eingestellt)... ist das ein 2*40 zeilen 
display in dem fall?
Gast #640190
Lesenswert?

1
;**********************************************************************************
2
;*
3
;* Title:       E+H Bypass Befüllungsanlage
4
;* Version:      Beta 0.1
5
;* Date:      20.08.2007
6
;* Build Date:
7
;* Author:      Adrian Bühlmann im Auftrag der
8
;*          Heinrich Kübler AG
9
;*          Ruessenstrasse 4
10
;*          CH-6340 Baar
11
;
12
;*
13
;* Description:    Mit dieser Steuerung können die E+H Bypässe
14
;*          mit Hilfe eines Bedienpanels befüllt bzw.
15
;*          entleert werden.
16
;*          Es werden Magnetventile sowie die Wasser-
17
;*          pumpe gesteuert. Dabei gelten folgende
18
;*          Definitionen:
19
;*
20
;*  Inputs:      Tast_Dauer_Be  --<  PortD,0
21
;*          Tast_Dauer_Ent  --< PortD,1
22
;*          Tast_Trig_Be  --< PortD,2
23
;*          Tast_Trig_Ent  --< PortD,3
24
;*          Tast_Vent1    --< PortD,4
25
;*          Tast_Vent2    --< PortD,5
26
;*          Tast_Pumpe    --< PortD,6
27
;*
28
;*  Outputs:    Vent1       -->  PortA,0
29
;*          Vent2       -->  PortA,1
30
;*          Pumpe       -->  PortA,2
31
;*
32
;*          LCD_RS      --> PortC,0
33
;*          LCD_RW      --> PortC,1
34
;*          LCD_E      --> PortC,2
35
;*          LCD_D1      --> PortC,3
36
;*          LCD_D2      --> PortC,4
37
;*          LCD_D3      --> PortC,5
38
;*          LCD_D4      --> PortC,6
39
;*
40
;*
41
;**********************************************************************************
42

43

44
;*** Definitions ***
45

46
; Processor
47
  list  p=16f877            ; Prozessordefinition
48

49
; Includefile
50
  #include "p16f877.inc"          ; Include Prozessorfile
51
  errorlevel  -302            ; error302 ausblenden
52

53
; Configurationbit
54
  __CONFIG b'11011100111010'        ; Prozessorkonfigurationen
55

56
; Variablen
57

58
loops    EQU  0x24
59
loops2    EQU  0x25
60

61
; Ports
62
#define Tast_Dauer_Be    PORTD,0      ;\
63
#define Tast_Dauer_Ent    PORTD,1      ;|
64
#define Tast_Trig_Be    PORTD,2      ;|
65
#define Tast_Trig_Ent    PORTD,3      ; > Tasterdefinitionen
66
#define Tast_Vent1      PORTD,4      ;|
67
#define Tast_Vent2      PORTD,5      ;|
68
#define Tast_Pumpe      PORTD,6      ;/
69

70
#define  LCD_E        PORTC,0      ;\
71
#define LCD_RS        PORTC,1      ;|
72
#define LCD_RW        PORTC,3      ;|
73
#define LCD_DB4        PORTC,4      ; > LCD Daten- und Steuerleitungen
74
#define LCD_DB5        PORTC,5      ;|
75
#define LCD_DB6        PORTC,6      ;|
76
#define LCD_DB7        PORTC,7      ;/
77

78
#define Vent1        PORTA,0      ;\
79
#define Vent2        PORTA,2      ; > Peripherie
80
#define Pumpe        PORTA,4      ;/
81
#define LEDstat        PORTA,3
82

83
;*** Program Start ***
84

85
      ORG    00h
86
      nop
87
      goto  INIT
88

89
;*** Initialisierung ***
90

91
      ORG  10h
92
INIT    bcf    STATUS, RP0
93
         bcf    STATUS, RP1
94
      clrf  PORTA
95
      clrf  PORTB
96
      clrf  PORTC
97
      clrf  PORTD
98
      clrf  PORTE
99
      clrf  PCLATH
100
      movlw  b'00000000'    ;20 Interrupt
101
      movwf  INTCON
102
      movlw  b'00000000'    ;51 Timer1 
103
      movwf  T1CON
104
      movlw  b'00000000'    ;55 Timer2
105
      movwf  T2CON
106
      movlw  b'00000000'    ;58 Capture, Compare, PWM
107
      movwf  CCP1CON
108
      movlw  b'00000000'    ;65 Serial Port
109
      movwf  SSPCON
110
      movlw  b'00000000'    ;96 USART
111
      movwf  RCSTA
112
      movlw  b'00000000'    ;111 AD Wandler
113
      movwf  ADCON0
114

115

116

117
      bsf    STATUS, RP0
118
      movlw  b'11111111'    ;19 Timer, WDT, Pullup, Interrupt
119
      movwf  OPTION_REG
120
      movlw  b'00000000'    ;30 Data Direction Port A
121
      movwf  TRISA
122
      movlw  b'00000000'    ;32 Data Direction Port B 
123
      movwf  TRISB
124
      movlw  b'00000000'    ;34 Data Direction Port C
125
      movwf  TRISC
126
      movlw  b'01111111'    ;35 Data Direction Port D
127
      movwf  TRISD
128
      movlw  b'00000000'    ;36 Data Direction Port E
129
      movwf  TRISE
130
      movlw  b'00000000'    ;66 Serial Port
131
      movwf  SSPCON2
132
      movlw  b'00000010'    ;95 USART
133
      movwf  TXSTA
134
      movlw  b'00000000'    ;97 BRG
135
      movwf  SPBRG
136
      movlw  b'00000110'    ;112 AD Wandler
137
      movwf  ADCON1
138
      bcf    STATUS, RP0
139

140

141
INITRAM    movlw  20h        ; Ram von 20 - 7f Hex nullen (Bank0)
142
      movwf  FSR
143
loop1    clrf  INDF
144
      incf  FSR,f
145
      movf  FSR,w
146
      sublw  80h
147
      bnz    loop1
148
      movlw  0a0h      ; Ram von a0 - ef Hex nullen (Bank1)
149
      movwf  FSR
150
loop2    clrf  INDF
151
      incf  FSR,f
152
      movf  FSR,w
153
      sublw  0f0h
154
      bnz    loop2
155

156
      goto  Start  
157
  
158
;** Subroutinen *********************************************************************************
159

160
WAIT
161
top        movlw   .110          
162
           movwf   loops2
163
top2      nop                   
164
           nop
165
           nop
166
           nop
167
           nop
168
           nop
169
           decfsz  loops2, F    
170
           goto    top2          
171
           decfsz  loops, F      
172
           goto    top           
173
           retlw  0            
174

175
InitLCD    movlw  d'45'
176
      movwf  loops
177
      call  WAIT
178
      bcf    LCD_RS
179
      bcf    LCD_RW
180
      bcf    LCD_DB7
181
      bcf    LCD_DB6
182
      bsf    LCD_DB5
183
      bsf    LCD_DB4
184
      call  Flanke  
185
      movlw  d'5'
186
      movwf  loops
187
      call  WAIT
188

189
      bcf    LCD_DB7
190
      bcf    LCD_DB6
191
      bsf    LCD_DB5
192
      bsf    LCD_DB4
193
      call  Flanke
194
      movlw  d'1'
195
      movwf  loops
196
      call  WAIT
197

198
      bcf    LCD_DB7
199
      bcf    LCD_DB6
200
      bsf    LCD_DB5
201
      bsf    LCD_DB4
202
      call  Flanke
203
      movlw  d'5'
204
      movwf  loops
205
      call  WAIT
206

207
      bcf    LCD_DB7      ;Fnction set
208
      bcf    LCD_DB6
209
      bsf    LCD_DB5
210
      bcf    LCD_DB4
211
      call  Flanke      
212

213
      bcf    LCD_DB7      ;2zeilen
214
      bcf    LCD_DB6
215
      bsf    LCD_DB5
216
      bcf    LCD_DB4
217
      call  Flanke
218

219
      bsf    LCD_DB7      ;function set 1
220
      bcf    LCD_DB6
221
      bsf    LCD_DB5
222
      bcf    LCD_DB4
223
      call  Flanke
224
      movlw  d'15'
225
      movwf  loops
226
      call  WAIT
227

228
      bcf    LCD_DB7      ;display an 1
229
      bcf    LCD_DB6
230
      bcf    LCD_DB5
231
      bcf    LCD_DB4
232
      call  Flanke
233

234
      bsf    LCD_DB7      ;display an 2
235
      bsf    LCD_DB6
236
      bcf    LCD_DB5
237
      bcf    LCD_DB4
238
      call  Flanke
239
      movlw  d'15'
240
      movwf  loops
241
      call  WAIT
242

243
      bcf    LCD_DB7      ;display löschen1
244
      bcf    LCD_DB6
245
      bcf    LCD_DB5
246
      bcf    LCD_DB4
247
      call  Flanke
248

249
      bcf    LCD_DB7      ;display löschen2
250
      bcf    LCD_DB6
251
      bcf    LCD_DB5
252
      bsf    LCD_DB4
253
      call  Flanke
254
      movlw  d'15'
255
      movwf  loops
256
      call  WAIT
257

258
      bcf    LCD_DB7      ;entry mode set1
259
      bcf    LCD_DB6
260
      bcf    LCD_DB5
261
      bcf    LCD_DB4
262
      call  Flanke
263

264
      bcf    LCD_DB7
265
      bsf    LCD_DB6
266
      bsf    LCD_DB5
267
      bcf    LCD_DB4
268
      call  Flanke
269
      movlw  d'15'
270
      movwf  loops
271
      call  WAIT
272
      return
273

274

275
Flanke    bsf    LCD_E
276
      nop
277
      movlw  d'15'
278
      movwf  loops
279
      call  WAIT
280
      bcf    LCD_E
281
      return
282

283

284

285

286

287

288
;** Main ****************************************************************************************
289

290
Start    bsf    LEDstat
291
      call  InitLCD  
292
      bcf    LEDstat
293

294
    END  
295

296
;************************************************************************************************

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren