Hallo,
ich habe ein kleines Problem mit einen LCD Display, ich kann zwar Daten
hinschicken, die auch angezeigt werden, allerdings hab ich keine Ahnung
wie ich sie positionieren soll. Das LCD Display fängt immer am Anfang
der ersten Zeile an...ich hab aber keine Ahnung wie ich in die zweite
komm!
#include <msp430x12x2.h>
;-----------------------------------------------------------------------
-------
; initialisation
;-----------------------------------------------------------------------
-------
RESET ORG 0E000h ; Flash
mov #WDTPW + WDTHOLD, &WDTCTL ; stop
call #LCD_INIT
eint
;-----------------------------------------------------------------------
-------
main
mov #1, R10
mov #000h, R11
call #SEND ; first nibble of display clear
mov #1, R10
mov #001h, R11
call #SEND
; send 'U' to display (ASCII 4Dh)
bis.b #BIT1, &P3OUT ; RS = 1 means
data
mov #1, R10
mov #005h, R11 ; high-nibble
first
call #SEND
mov #1, R10
mov #005h, R11 ; low-nibble
call #SEND
bic.b #BIT1, &P3OUT
;
;-----------------------------------------------------------------------
-------
; LCD initialisation sub routine
;-----------------------------------------------------------------------
-------
LCD_INIT mov.b #000h, &P1OUT ; set data lines DB4-DB7
mov.b #00fh, &P1DIR
mov.b #000h, &P3OUT ; set EN and RS line
mov.b #003h, &P3DIR
mov #16, R10 ; counter (16 * 1ms)
call #DELAY ; wait R10 * 1ms
mov #003h, R11 ; standard init routine
mov #5, R10
call #SEND ; send init code first time
mov #1, R10
call #SEND ; send init code second time
mov #1, R10
call #SEND ; send init code third time
mov #1, R10
mov #002h, R11
call #SEND ; define 4-Bit communication
mov #1, R10
mov #002h, R11
call #SEND ; first nibble of function set
mov #1, R10
mov #008h, R11
call #SEND ; second nibble of function set
; 2 lines, 5x7 dots
mov #1, R10
mov #000h, R11
call #SEND ; first nibble of display control
mov #1, R10
mov #00Ch, R11
call #SEND ; second nibble of display control
; display on, cursor off
mov #1, R10
mov #000h, R11
call #SEND ; first nibble of display clear
mov #1, R10
mov #001h, R11
call #SEND ; second nibble of display clear
mov #1, R10
mov #000h, R11
call #SEND ; first nibble of entry mode set
mov #1, R10
mov #006h, R11
call #SEND ; second nibble of entry mode set
; increment address counter
ret
;--------------------------------
----------------------------------------------
; send Data via Port1 (P1.0-P1.3) to LCD - subroutine
;-----------------------------------------------------------------------
-------
SEND bis.b #BIT0, &P3OUT ; EN = 1
mov.b R11, &P1OUT ; data to DB4-DB7
bic.b #BIT0, &P3OUT ; EN = 0
call #DELAY
ret
;-----------------------------------------------------------------------
-------
; Delay - sub routine
;-----------------------------------------------------------------------
-------
DELAY mov #03E8h,R12 ; value for counting back
LOOP dec R12
jnz LOOP
dec R10 ; multipier for LOOP
jnz DELAY
ret
;
; Interrupt Vectors Used MSP430x1232
;-----------------------------------------------------------------------
-------
ORG 0FFFEh ; MSP430 RESET Vector
DW RESET
END
Du musst die DD RAM ADDRESS setzen mit Kommando 0b001xxxxx, wobei xxxxx die Adresse ist. Vorsicht, die Adressen sind nicht ganz linear verteilt. Siehe Datenblatt. MFG Falk
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.