Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. list P=16F877
  2.  
  3. status  equ     0x03
  4. portd   equ     0x08
  5. trisd   equ     0x88
  6. RP0     equ     0x05
  7. En      equ     0x01
  8.  
  9. Timer1  equ     0x20
  10. Timer2  equ     0x21
  11. Times   equ     0x23
  12. TabPek  equ     0x24
  13. ASCII   equ     0x25
  14. Z       equ     0x02
  15. PCL     equ     0x02
  16.  
  17. ;**********************
  18. org     0x00
  19. clrf    status
  20. movlw   0x00
  21. movwf   0x0A
  22. goto    Init
  23. ;******** Subrutiner
  24.  
  25. waitms      movlw   0x0a
  26.     movwf   Timer2
  27. wait_loop2  movlw   0x64
  28.     movwf   Timer1
  29. wait_loop1  decfsz  Timer1,1
  30.  
  31.     goto    wait_loop1
  32.     decfsz  Timer2,1
  33.  
  34.     goto    wait_loop2
  35.     return
  36.  
  37. ; ********* Enable
  38.  
  39. Enable  bsf     portd,En
  40.     call    waitms
  41.     bcf     portd,En
  42.     call    waitms
  43. return
  44.  
  45. ;*********** LCD_Init
  46.  
  47. LCD_Init    movlw   0xff
  48.     movwf   Times
  49. lcd_loop3   call    waitms
  50.     decfsz  Times,1
  51.     goto    lcd_loop3
  52.  
  53.     movlw   0x30
  54.     movwf   portd
  55.     call    Enable
  56.  
  57.     movlw   0x05
  58.     movwf   Times
  59. lcd_loop4   call    waitms
  60.     decfsz  Times,1
  61.     goto    lcd_loop4
  62.  
  63.     movlw   0x30   
  64.     movwf   portd
  65.     call    Enable
  66.  
  67.     call    waitms
  68.  
  69.     movlw   0x30
  70.     movwf   portd
  71.     call    Enable
  72.  
  73.     movlw   0x20
  74.     movwf   portd
  75.     call    Enable
  76.     call    waitms
  77.  
  78.     movlw   0x20
  79.     movwf   portd
  80.     call    Enable
  81.     movlw   0x80
  82.     movwf   portd
  83.     call    Enable
  84.     call    waitms
  85.  
  86.     movlw   0x00
  87.     movwf   portd
  88.     call    Enable
  89.     movlw   0x10
  90.     movwf   portd
  91.     call    Enable
  92.     call    waitms
  93.  
  94.     movlw   0x00
  95.     movwf   portd
  96.     call    Enable
  97.     movlw   0x60
  98.     movwf   portd
  99.     call    Enable
  100.     call    waitms
  101.  
  102.     movlw   0x00
  103.     movwf   portd
  104.     call    Enable
  105.     movlw   0xe0
  106.     movwf   portd
  107.     call    Enable
  108.     call    waitms 
  109. return
  110.  
  111. ;********* Text tabellen
  112.  
  113. TEXT    
  114.     addwf   PCL,f
  115.     retlw   'A'
  116.     retlw   'B'
  117.     retlw   'C'
  118.     retlw   'D'
  119.     retlw   'E'
  120.     retlw   'F'
  121.     retlw   'G'
  122.     retlw   0x00
  123. return
  124.  
  125. VisaLCD
  126.     movwf   ASCII
  127.     andlw   0xF0
  128.     movwf   portd
  129.     bsf     portd,0
  130.     call    Enable
  131.     swapf   ASCII,w
  132.     andlw   0x0F
  133.     movwf   portd
  134.     incf    portd,f
  135.     call    Enable
  136. return
  137.  
  138. ;********* Init
  139. Init    clrw
  140.         movwf   portd
  141.         bsf     status,RP0
  142.         movwf   trisd
  143.         bcf     status,RP0
  144. Main    call    LCD_Init
  145.         clrf    TabPek
  146. Igen    movfw   TabPek
  147.         call    TEXT
  148.         iorlw   0x00
  149.         btfsc   status, Z
  150.         goto    Klar
  151.         call    VisaLCD
  152.         incf    TabPek
  153.         goto    Igen
  154. Klar    goto    Klar
  155. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement