ervinne

Micro Sys. Lab 4 Ex. 02 - Computed Delay (1s)

Sep 8th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 1.06 KB | None | 0 0
  1.     #INCLUDE "P16F84A.INC"
  2.  
  3.     __CONFIG _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF
  4.  
  5.     ERRORLEVEL -302
  6.  
  7.     ;----------------------------------------------------------
  8.     ;   variable declaration
  9.     COUNTERA EQU H'10'
  10.     COUNTERB EQU H'11'
  11.  
  12.     ORG 0x00
  13.     GOTO START
  14.  
  15.     ORG 0x04
  16.     GOTO START
  17.  
  18. START
  19.     ;----------------------------------------------------------
  20.     ;   register configurations
  21.     BSF STATUS, RP0
  22.     MOVLW 0x00
  23.     MOVWF TRISB
  24.  
  25.     MOVLW 0x07
  26.     MOVWF OPTION_REG
  27.  
  28.     BCF STATUS, RP0
  29.     CLRF PORTB
  30.  
  31. MAIN
  32.     ;---------------------------------------------------------
  33.     ;   loop of the program
  34.    
  35.     MOVLW 0xF0
  36.     MOVWF PORTB
  37.     CALL DELAY
  38.  
  39.     MOVLW 0x0F
  40.     MOVWF PORTB
  41.     CALL DELAY
  42.  
  43.     GOTO MAIN
  44.  
  45. DELAY
  46.     ;---------------------------------------------------------
  47.     ;   create a delay
  48.     MOVLW D'1'
  49.     MOVWF COUNTERA
  50.  
  51. LOOPA
  52.     CALL DELAYA
  53.     DECFSZ COUNTERA, 1
  54.     GOTO LOOPA
  55.     RETLW 0x00
  56.  
  57. DELAYA
  58.     MOVLW D'15'
  59.     MOVWF COUNTERB
  60.  
  61. LOOPB
  62.     CALL DELAYB
  63.     DECFSZ COUNTERB, 1
  64.     GOTO LOOPB
  65.     RETLW 0x00
  66.  
  67. DELAYB
  68.     CLRF TMR0
  69.     BCF INTCON, T0IF
  70. LOOPC
  71.     BTFSS INTCON, T0IF
  72.     GOTO LOOPC
  73.     RETLW 0x00
  74.    
  75.     END
Advertisement
Add Comment
Please, Sign In to add comment