Advertisement
Guest User

Untitled

a guest
Apr 17th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;ZADAMNIE 1 WYUISZ NAPIS PO LITERCE NA EKLRANIE "EWELINA WRUC"
  2.  
  3. ; PUBLIC       putcharLCD, putstrLCD, initLCD, putctrlLCD
  4. ; LCD registers           ----------------------------------
  5.  
  6. LCDstatus  equ 0FF2EH        
  7. LCDcontrol equ 0FF2CH
  8. LCDdataWR  equ 0FF2DH
  9. LCDdataRD  equ 0FF2FH              
  10.  
  11. // LCD control bytes       ---------------------------------
  12.  
  13. #define  HOME     0x80    // put curcor to second line  
  14. #define  INITDISP 0x38    // LCD init (8-bit mode)  
  15. #define  HOM2     0xc0    // put curcor to second line  
  16. #define  LCDON    0x0e    // LCD nn, cursor off, blinking of
  17. #define  CLEAR    0x01    // LCD display clear
  18.  
  19. TIME        EQU 50; ms
  20. CYCLES      EQU (65536 - 1000 * TIME)
  21.  
  22. CNT_S       EQU     30h
  23. SEC         EQU     31h
  24.  
  25.         ORG 0
  26.  
  27.         LJMP START
  28.  
  29.         ORG 0Bh
  30. t0_interrupt:                   ; Przerwanie timera 0
  31.         mov TL0, #LOW(CYCLES)
  32.         mov TH0, #HIGH(CYCLES)
  33.  
  34.         DJNZ CNT_S, int_exit
  35.         MOV CNT_S, #20
  36.  
  37.         INC SEC
  38.         ; czy sec = 60
  39.         MOV A, R2
  40.        
  41.  
  42.  
  43. int_exit:
  44.         RETI
  45.  
  46.  
  47. START:
  48.         lcd_init
  49.  
  50.         MOV R1, #20D            ;1/20sekundy
  51.         MOV R2, #0              ;sekundy
  52.         MOV R3, #0              ;minuty
  53.         MOV R4, #0              ;godziny
  54.  
  55.         LCALL configure_timer_50_ms
  56.         NOP
  57.         NOP
  58.         NOP
  59.         JMP $
  60.  
  61. ;-------------------------------------------------------------------------------------------------
  62. wait_lcd_busy:
  63.             MOV    DPTR,#LCDstatus
  64.             MOVX   A,@DPTR
  65.             JB     ACC.7,wait_lcd_busy       ; check if LCD busy
  66. RET
  67.  
  68. wr_cmd MACRO command
  69.             LCALL wait_lcd_busy
  70.  
  71.             MOV    DPTR,#LCDcontrol ; write to LCD control
  72.             MOV    A, command
  73.             MOVX   @DPTR,A
  74.             ENDM
  75.  
  76. lcd_putch MACRO
  77.                             PUSH ACC
  78.                             LCALL wait_lcd_busy
  79.  
  80.                             MOV     DPTR,#LCDdataWR; Set the datapointer to the adress when the LCD is mapped for char writing
  81.    
  82.                             POP     ACC
  83.                             MOVX    @DPTR, A                ; write data to LCD
  84.                         ENDM
  85.  
  86. lcd_init  MACRO
  87.          wr_cmd #INITDISP
  88.          wr_cmd #CLEAR
  89.          wr_cmd #LCDON  
  90. ENDM
  91.  
  92. ;-----------------------------------------------------------
  93. ; Konfiguracja timera na tryb odliczania czasu 50 ms
  94. ;-----------------------------------------------------------
  95. configure_timer_50_ms:
  96.         clr TR0                 ; Zatrzymanie timera
  97.         mov TMOD, #00000001b    ; Tryb 16bit
  98.        
  99.         mov TL0, #LOW(CYCLES)
  100.         mov TH0, #HIGH(CYCLES)
  101.  
  102.         clr TF0                 ; Wyczyszczenie flagi przepelnienia
  103.         setb EA                ;wlacza system przerwan
  104.         setb ET0                ;uruchom przerwania timera 0
  105.         setb TR0                ; uruchum timer 0
  106.         RET
  107.  
  108.    
  109. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement