Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;ZADAMNIE 1 WYUISZ NAPIS PO LITERCE NA EKLRANIE "EWELINA WRUC"
- ; PUBLIC putcharLCD, putstrLCD, initLCD, putctrlLCD
- ; LCD registers ----------------------------------
- LCDstatus equ 0FF2EH
- LCDcontrol equ 0FF2CH
- LCDdataWR equ 0FF2DH
- LCDdataRD equ 0FF2FH
- // LCD control bytes ---------------------------------
- #define HOME 0x80 // put curcor to second line
- #define INITDISP 0x38 // LCD init (8-bit mode)
- #define HOM2 0xc0 // put curcor to second line
- #define LCDON 0x0e // LCD nn, cursor off, blinking of
- #define CLEAR 0x01 // LCD display clear
- TIME EQU 50; ms
- CYCLES EQU (65536 - 1000 * TIME)
- CNT_S EQU 30h
- SEC EQU 31h
- ORG 0
- LJMP START
- ORG 0Bh
- t0_interrupt: ; Przerwanie timera 0
- mov TL0, #LOW(CYCLES)
- mov TH0, #HIGH(CYCLES)
- DJNZ CNT_S, int_exit
- MOV CNT_S, #20
- INC SEC
- ; czy sec = 60
- MOV A, R2
- int_exit:
- RETI
- START:
- lcd_init
- MOV R1, #20D ;1/20sekundy
- MOV R2, #0 ;sekundy
- MOV R3, #0 ;minuty
- MOV R4, #0 ;godziny
- LCALL configure_timer_50_ms
- NOP
- NOP
- NOP
- JMP $
- ;-------------------------------------------------------------------------------------------------
- wait_lcd_busy:
- MOV DPTR,#LCDstatus
- MOVX A,@DPTR
- JB ACC.7,wait_lcd_busy ; check if LCD busy
- RET
- wr_cmd MACRO command
- LCALL wait_lcd_busy
- MOV DPTR,#LCDcontrol ; write to LCD control
- MOV A, command
- MOVX @DPTR,A
- ENDM
- lcd_putch MACRO
- PUSH ACC
- LCALL wait_lcd_busy
- MOV DPTR,#LCDdataWR; Set the datapointer to the adress when the LCD is mapped for char writing
- POP ACC
- MOVX @DPTR, A ; write data to LCD
- ENDM
- lcd_init MACRO
- wr_cmd #INITDISP
- wr_cmd #CLEAR
- wr_cmd #LCDON
- ENDM
- ;-----------------------------------------------------------
- ; Konfiguracja timera na tryb odliczania czasu 50 ms
- ;-----------------------------------------------------------
- configure_timer_50_ms:
- clr TR0 ; Zatrzymanie timera
- mov TMOD, #00000001b ; Tryb 16bit
- mov TL0, #LOW(CYCLES)
- mov TH0, #HIGH(CYCLES)
- clr TF0 ; Wyczyszczenie flagi przepelnienia
- setb EA ;wlacza system przerwan
- setb ET0 ;uruchom przerwania timera 0
- setb TR0 ; uruchum timer 0
- RET
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement