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_ON & _CPD_OFF & _WRT_ALL
- cblock 0x20
- d1 ;0x20
- d2 ;0x21
- d3 ;0x22
- endc
- RES_VECT CODE 0x0000 ; processor reset vector
- GOTO loop ; go to beginning of program
- ; TODO ADD INTERRUPTS HERE IF USED
- MAIN_PROG CODE ; let linker place main program
- loop
- clrf PORTB ;clear PORTB //just for safety
- BANKSEL TRISB ;Select TRISB Bank
- movlw b'11111110' ;Set RB0 as Output
- movwf TRISB ;Set RB0 as Output
- BANKSEL PORTB ;Select PORTB Bank
- btfsc PORTB,RB1 ;Skip next Line of Code, if RB1 is LOW
- call _toggle_RB0 ;Blink LED attached to RB0
- goto loop
- _toggle_RB0
- bsf PORTB,RB0 ;Turn on RB0
- call _delay_1s ;wait a 'sec
- bcf PORTB,RB0 ;Turn off RB0
- call _delay_1s ;wait a 'sec
- return
- _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