Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "p16F870.inc"
- ; CONFIG
- ; __config 0xFFBA
- __CONFIG _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _CP_OFF & _BOREN_OFF & _LVP_OFF & _CPD_OFF & _WRT_ALL
- cblock 0x20
- d1 ;0x20
- d2 ;0x21
- d3 ;0x22
- ledctr ;0x23
- endc
- RES_VECT CODE 0x0000 ; processor reset vector
- GOTO MAIN ; go to beginning of program
- ; TODO ADD INTERRUPTS HERE IF USED
- MAIN_PROG CODE ; let linker place main program
- MAIN
- bsf STATUS,C ;Set Carry bit for rotate-instruction
- clrf PORTB ;Clear PORTB //just for safety
- BANKSEL TRISB ;Select TRISB Bank
- movlw b'11100000' ;Set RB0-RB4 as Output
- movwf TRISB ;Set RB0-RB4 as Output
- BANKSEL PORTB ;Select PORTB Bank
- movlw 0x05 ;Preload 5 into ledctr
- movwf ledctr ;Preload 5 into ledctr
- _rotateportb
- rlf PORTB ;rotate PORTB Left
- call _delay_1s ;wait a 'sec
- decfsz ledctr, f ;decrease ledctr
- goto _rotateportb
- GOTO MAIN ; loop forever
- _delay_1s
- ;2499992 cycles
- movlw 0x15
- movwf d1
- movlw 0x74
- movwf d2
- movlw 0x06
- movwf d3
- _delay_1s_0
- decfsz d1, f
- goto $+2
- decfsz d2, f
- goto $+2
- decfsz d3, f
- goto _delay_1s_0
- ;4 cycles
- goto $+1
- goto $+1
- ;4 cycles (including call)
- return
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement