hallo,
Ik heb een tijd geleden al een programma geschreven voor
lcd display, maar kan het niet meer terug vinden. Heb dus
het programma opnieuw geschreven met mplab in asm. maar om
de een of andere reden wordt het eerste karakter op de
eerste lijn met het sommatie teken ingevuld en wordt de
eigelijke tekst pas op het 2de karater van de eerste lijn
gezet. het laatste karakter van de 2delijn wordt niet meer
getoont. het betreft hier en display met 2 x 40 karakters
met HD44780 controller.
de code : de initialisatie lijkt mij goed omdat er tekens
op het display komen (het programma zal wss niet perfect
zijn maar werkt wel).
ik krijg dus : _ = spatie
Emenu_welkom_________water=25-C_21:15:21
tijd_instellen_____lucht=35-C_______5ja
daarna ga ik terug naar eerste lijn via return_home
en schrijf ik 5jan en krijg ik
b5jaù ...
dus ik denk dat er ergens een fout zit in lcd_display
subroutine waar de tekst geschreven wordt
in ieder geval bedankt.
processor 16F877
porta EQU 0x05
portb EQU 0x06
trisa EQU 0x85
trisb EQU 0x86
RP0 EQU 5
RP1 EQU 6
intcon EQU 0x0B
option_reg EQU 0x81
usteller EQU 0x20
msteller EQU 0x21
steller EQU 0x22
svrWREG EQU 0x23
svrSTATUS EQU 0x24
tiendeteller EQU 0x25
minteller EQU 0x26
status EQU 0x03
RS EQU 2
enable EQU 3
getal EQU 0x27
flag EQU 0x28 ; om te kijken wanneer de 2de reeks doorgestuurd wordt naar de lcd
TMR0 EQU 0x01
T0IF EQU 2
zero EQU 2
ADCON1 EQU 0x9F
GOTO main
ORG 0004h
;-**********************interrupt**********************
int_timer
MOVWF svrWREG
SWAPF status,W
BCF 0x03,RP0
BCF 0x03,RP1
MOVWF svrSTATUS
BCF intcon,T0IF ;TMR0 terug op 9
MOVLW .134
MOVWF TMR0
INCF usteller,1 ; usteller++
MOVF usteller,W
XORLW .10
BTFSS status,zero
GOTO restore_registers
INCF msteller,1 ; msteller++
CLRF usteller
MOVF msteller,W
XORLW .100
BTFSS status,zero
GOTO restore_registers
INCF tiendeteller,1 ; tiendeteller++
CLRF msteller
MOVF tiendeteller,W
XORLW .10
BTFSS status,zero
GOTO restore_registers
INCF steller,1 ;sec teller
CLRF tiendeteller
MOVF steller,W
XORLW .60
BTFSS status,zero
GOTO restore_registers
INCF minteller,1 ; minteller++
CLRF steller
restore_registers BCF 0x03,RP0
BCF 0x03,RP1
SWAPF svrSTATUS,W
MOVWF status
SWAPF svrWREG,1
SWAPF svrWREG,W
RETFIE
;*********************LCD-programma*****************
LCD_INIT
BCF porta,RS
MOVLW 0x30
CALL write_LCD2
MOVLW 0x30
CALL write_LCD2
MOVLW 0x30
CALL write_LCD2
MOVLW 0x20
CALL write_LCD2
MOVLW 0x20
CALL write_LCD2
MOVLW 0x80
CALL write_LCD2
MOVLW 0x00
CALL write_LCD2
MOVLW 0x60
CALL write_LCD2
MOVLW 0x00
CALL write_LCD2
MOVLW 0xe0
CALL write_LCD2
RETURN
;***************delay********************
delay
CLRF msteller
CLRF usteller
terug MOVF msteller,W
XORLW .5
BTFSS status,zero
goto terug
RETURN
;*********************delay2***************************
delay2
CLRF usteller
terug3 MOVF usteller,W
XORLW .3
BTFSS status,zero
goto terug3
RETURN
;******************write_lcd2**************************
write_LCD2 ; initialisatie schrijven
BCF porta,enable
MOVWF getal
BTFSC getal,7
BSF portb,7
BTFSS getal,7
BCF portb,7
BTFSC getal,6
BSF portb,6
BTFSS getal,6
BCF portb,6
BTFSC getal,5
BSF portb,5
BTFSS getal,5
BCF portb,5
BTFSC getal,4
BSF portb,4
BTFSS getal,4
BCF portb,4
BSF porta,enable
CALL delay
RETURN
;*******************write_lcd*****************************
write_LCD ;data schrijven naar lcd
BCF porta,enable
MOVWF getal
GOTO verder
lijn_2 MOVLW 0x02
MOVWF flag
BSF porta,enable
CALL delay
BCF porta,enable
verder
BTFSC getal,7
BSF portb,7
BTFSS getal,7
BCF portb,7
BTFSC getal,6
BSF portb,6
BTFSS getal,6
BCF portb,6
BTFSC getal,5
BSF portb,5
BTFSS getal,5
BCF portb,5
BTFSC getal,4
BSF portb,4
BTFSS getal,4
BCF portb,4
SWAPF getal,1
BTFSS flag,1 ; als deze bit 1 is,is de 2de lijn geschreven en moet de volgende functie overgeslagen worden
GOTO lijn_2
terug2 MOVLW 0x01
MOVWF flag
BSF porta,enable
CALL delay
RETURN
;********************cursor_right*************************
cursor_right
BCF porta,RS
MOVLW 0x14
CALL write_LCD
BSF porta,RS
RETURN
;*****************return_home**************************
return_home
BCF porta,RS
Call delay
MOVLW 0x02 ;naar begin van 1ste lijn
CALL write_LCD
BSF porta,RS
RETURN
;********************second_line*************************
second_line
BCF porta,RS
MOVLW 0x40
CALL write_LCD
MOVLW 0xc0
CALL write_LCD
BSF porta, RS
RETURN
;*******************clear_display*************
clear_display
BCF porta,RS
MOVLW 0x01
call write_LCD
BSF porta,RS
RETURN
;**************lcd-programma*****************************
LCD_display
CALL delay
CALL delay
Call delay
Call LCD_INIT
MOVLW 0x01
MOVWF flag ; nu zitten we in de tekst fase dus 2 maal doorsturen
BSF porta,RS
MOVLW 'm'
Call write_LCD
MOVLW 'e'
Call write_LCD
MOVLW 'n'
Call write_LCD
MOVLW 'u'
Call write_LCD
MOVLW 0x20
Call write_LCD
MOVLW 'w'
Call write_LCD
MOVLW 'e'
Call write_LCD
MOVLW 'l'
Call write_LCD
MOVLW 'k'
Call write_LCD
MOVLW 'o'
Call write_LCD
MOVLW 'm'
Call write_LCD
MOVLW 0x20
Call write_LCD;
MOVLW 0x20
Call write_LCD;
MOVLW 0x20
Call write_LCD
MOVLW 0x20
Call write_LCD
MOVLW 0x20
Call write_LCD
MOVLW 0x20
Call write_LCD
MOVLW 0x20
Call write_LCD
MOVLW 0x20
Call write_LCD
MOVLW 0x20
Call write_LCD
MOVLW 'w'
Call write_LCD
MOVLW 'a'
Call write_LCD
MOVLW 't'
Call write_LCD
MOVLW 'e'
Call write_LCD
MOVLW 'r'
Call write_LCD
MOVLW '='
Call write_LCD
MOVLW '2'
Call write_LCD
MOVLW '5'
Call write_LCD
MOVLW '°'
Call write_LCD
MOVLW 'C'
Call write_LCD
MOVLW 0x20
Call write_LCD
MOVLW '2'
Call write_LCD;
MOVLW '1'
Call write_LCD;
MOVLW ':'
Call write_LCD
MOVLW '1'
Call write_LCD
MOVLW '5'
Call write_LCD
MOVLW ':'
Call write_LCD
MOVLW '2'
Call write_LCD
MOVLW '1'
Call write_LCD
MOVLW 't'
call write_LCD
MOVLW 'i'
call write_LCD
MOVLW 'j'
call write_LCD
MOVLW 'd'
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 'i'
call write_LCD
MOVLW 'n'
call write_LCD
MOVLW 's'
call write_LCD
MOVLW 't'
call write_LCD
MOVLW 'e'
call write_LCD
MOVLW 'l'
call write_LCD
MOVLW 'l'
call write_LCD
MOVLW 'e'
call write_LCD
MOVLW 'n'
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 'l'
call write_LCD
MOVLW 'u'
call write_LCD
MOVLW 'c'
call write_LCD
MOVLW 'h'
call write_LCD
MOVLW 't'
call write_LCD
MOVLW '='
call write_LCD
MOVLW '3'
call write_LCD
MOVLW '5'
call write_LCD
MOVLW '°'
call write_LCD
MOVLW 'C'
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW 0x20
call write_LCD
MOVLW '5'
call write_LCD
MOVLW 'j'
call write_LCD
MOVLW 'a'
call write_LCD
MOVLW 'n'
call write_LCD
call cursor_right
call return_home
MOVLW '5'
call write_LCD
MOVLW 'j'
call write_LCD
MOVLW 'a'
call write_LCD
MOVLW 'n'
call write_LCD
call cursor_right
RETURN
;***********************hoofdprogramma******************
main
BSF 03,RP0 ; begin main programma
BCF 03,RP1 ; trisa en b instellen
CLRF trisa
CLRF trisb
MOVLW 0x06 ;comparatoren uitschakelen
MOVWF ADCON1
MOVLW 0x01
MOVWF option_reg ; deler insteller
BCF 03,RP0
CLRF porta
CLRF portb
MOVLW 0xA0
MOVWF intcon ; interrupt instellen
MOVLW .134
MOVWF TMR0
CALL LCD_display
lus NOP
GOTO lus
END
Fantomaz
Ik moet hier weer vaker komen... Wat kun je zo'n forum als deze gaan missen. :-)
picsels
Volgend project: 7-seg gaming displays; dan dec-1982 labvoeding afmaken, dan funcgen met ad9833 afmaken, dan...
Op 13 januari 2007 22:56:00 schreef Fantomaz:
Doe eens gek en probeer PICbasic...
Of gebruik macro's, define's, de Microchip includefile, CBLOCK, etc...