Elektroda.pl
Elektroda.pl
X
Prosz, dodaj wyj徠ek www.elektroda.pl do Adblock.
Dzi瘯i temu, 瞠 ogl康asz reklamy, wspierasz portal i u篡tkownik闚.

DSM-51 S這wo MARCIN ble ble ble ble

nancin1q 24 Maj 2017 13:39 1059 0
  • #1 24 Maj 2017 13:39
    nancin1q
    Poziom 1  

    Siema
    Czy ktos moze mi napisac gotowy kod zeby dalo sie odpalic w tym dsm s這wo marcin? Tak zeby wyswietlalo na lcd jestem zielony a potrzebuje to. Mam takie ale nei dzialaja do tego wywala mi blad formatu pliku hex a mam w rozszerzeniu .hex nie ogarniam, a tu sa kody ktore wlasnie nie trybia: 1.
    START:
    LCALL INIT_LCD
    LCALL CLEAR_LCD
    MOV A,#'M'
    LCALL WRITE_TEXT
    MOV A,#'A'
    LCALL WRITE_TEXT
    MOV A,#'R'
    LCALL WRITE_TEXT
    MOV A,#'C'
    LCALL WRITE_TEXT
    MOV A,#'I'
    LCALL WRITE_TEXT
    MOV A,#'N'
    END:


    2.

    START:
    lcd_port EQU P1 ;The port that I send data to LCD
    data EQU #41H ;Some random register in internal data memory

    MOV DPTR, #my_string
    ACALL lcd_string ;This function will write on LCD some string

    MOV A, R1 ;In case that R1 is my variable
    MOV data, A
    ACALL lcd_dta ;Writes R1 value on LCD

    lcd_string:
    MOV A, #0x00
    MOVC A, @A+DPTR
    JZ end_lcd_string
    MOV DATA, A
    CALL lcd_data
    INC DPTR
    JMP lcd_string
    end_lcd_string:
    RET

    lcd_data:
    CALL lcd_busy ;verify if the LCD is busy, just like your function
    SETB LCD_RS ;Set bit on LCD RS pin
    SETB LCD_E ;Set bit on LCD Enable pin
    MOV lcd_port ;Move your data to LCD
    CLR LCD_E ;Turn LCD Enable pin to 0
    RET

    my_string:
    DB 'MARCIN'
    END:

    3.

    START:
    lcd_cmd equ 0800h ;Write COMMAND reg address 0800h
    lcd_st equ 0801h ;Read STATUS reg address 0801h
    lcd_wr equ 0802h ;Write DATA reg address 0802h
    lcd_rd equ 0803h ;Read DATA reg address 0803h

    ORG 08100h

    hello:
    mov P2, #(lcd_cmd SHR 8) ;load P2 with high address
    mov R0, #(lcd_cmd AND 255) ;load R0 with command reg addr
    mov R7, #03h ;set LCD position, line=1, char=3
    mov dptr, #mesg1 ;point to mesg1
    acall wr_string ;write mesg1 to LCD

    mov R7, #41h ;set LCD position, line= 2, char=1
    mov dptr, #mesg2 ;point to mesg2
    acall wr_string ;write mesg2 to LCD

    stop: ajmp stop ;soft halt

    wr_string:
    acall lcd_busy ;wait until LCD not busy
    mov a, R7 ;get LCD position
    orl a, #080h ;msb set for LCD RAM address
    movx @R0, a ;write lcd_cmd to set line & char
    nxt_char:
    acall lcd_busy ;wait until LCD not busy
    clr a
    movc a, @a+dptr
    inc dptr ;point to next byte in string
    jz str_end ;if 0 then end of string

    mov R1, #(lcd_wr AND 255) ;Load R1 with wr_data address
    movx @R1, a ;Write char to LCD
    sjmp nxt_char ;get next char in string
    str_end: ret

    lcd_busy:
    mov R1, #(lcd_st AND 255) ;Load R1 with status address
    movx a, @R1 ;read LCD status
    jb acc.7, lcd_busy ;keep checking until busy bit clear
    ret

    mesg1: db "MARCIN",0
    END:

    pomocyyyy

    0 0