Advertisement
Guest User

Untitled

a guest
Sep 13th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include "p16F870.inc"
  2.  
  3. ; CONFIG
  4. ; __config 0xFFBA
  5. __CONFIG _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _CP_OFF & _BOREN_OFF & _LVP_ON & _CPD_OFF & _WRT_ALL
  6.  
  7.  
  8. cblock 0x20
  9. d1 ;0x20
  10. d2 ;0x21
  11. d3 ;0x22
  12. endc
  13.  
  14.  
  15. RES_VECT CODE 0x0000 ; processor reset vector
  16. GOTO loop ; go to beginning of program
  17.  
  18. ; TODO ADD INTERRUPTS HERE IF USED
  19.  
  20. MAIN_PROG CODE ; let linker place main program
  21.  
  22. loop
  23.  
  24. clrf PORTB ;clear PORTB //just for safety
  25.  
  26. BANKSEL TRISB ;Select TRISB Bank
  27. movlw b'11111110' ;Set RB0 as Output
  28. movwf TRISB ;Set RB0 as Output
  29.  
  30. BANKSEL PORTB ;Select PORTB Bank
  31. btfsc PORTB,RB1 ;Skip next Line of Code, if RB1 is LOW
  32. call _toggle_RB0 ;Blink LED attached to RB0
  33.  
  34. goto loop
  35.  
  36.  
  37. _toggle_RB0
  38. bsf PORTB,RB0 ;Turn on RB0
  39. call _delay_1s ;wait a 'sec
  40. bcf PORTB,RB0 ;Turn off RB0
  41. call _delay_1s ;wait a 'sec
  42. return
  43.  
  44.  
  45.  
  46. _delay_1s
  47. ;2499992 cycles
  48. movlw 0x15
  49. movwf d1
  50. movlw 0x74
  51. movwf d2
  52. movlw 0x06
  53. movwf d3
  54. _delay_1s_0
  55. decfsz d1, f
  56. goto $+2
  57. decfsz d2, f
  58. goto $+2
  59. decfsz d3, f
  60. goto _delay_1s_0
  61.  
  62. ;4 cycles
  63. goto $+1
  64. goto $+1
  65.  
  66. ;4 cycles (including call)
  67. return
  68.  
  69.  
  70.  
  71.  
  72. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement