Advertisement
Guest User

Untitled

a guest
Sep 13th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 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_OFF & _CPD_OFF & _WRT_ALL
  6.  
  7.  
  8. cblock 0x20
  9. d1 ;0x20
  10. d2 ;0x21
  11. d3 ;0x22
  12. ledctr ;0x23
  13. endc
  14.  
  15. RES_VECT CODE 0x0000 ; processor reset vector
  16. GOTO MAIN ; 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. MAIN
  23. bsf STATUS,C ;Set Carry bit for rotate-instruction
  24.  
  25. clrf PORTB ;Clear PORTB //just for safety
  26.  
  27. BANKSEL TRISB ;Select TRISB Bank
  28. movlw b'11100000' ;Set RB0-RB4 as Output
  29. movwf TRISB ;Set RB0-RB4 as Output
  30.  
  31. BANKSEL PORTB ;Select PORTB Bank
  32.  
  33. movlw 0x05 ;Preload 5 into ledctr
  34. movwf ledctr ;Preload 5 into ledctr
  35.  
  36. _rotateportb
  37. rlf PORTB ;rotate PORTB Left
  38. call _delay_1s ;wait a 'sec
  39. decfsz ledctr, f ;decrease ledctr
  40. goto _rotateportb
  41.  
  42. GOTO MAIN ; loop forever
  43.  
  44. _delay_1s
  45. ;2499992 cycles
  46. movlw 0x15
  47. movwf d1
  48. movlw 0x74
  49. movwf d2
  50. movlw 0x06
  51. movwf d3
  52. _delay_1s_0
  53. decfsz d1, f
  54. goto $+2
  55. decfsz d2, f
  56. goto $+2
  57. decfsz d3, f
  58. goto _delay_1s_0
  59.  
  60. ;4 cycles
  61. goto $+1
  62. goto $+1
  63.  
  64. ;4 cycles (including call)
  65. return
  66.  
  67.  
  68.  
  69.  
  70. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement