Cantafford
Member
Hey,
I have 5 LEDs on PORTB of a PIC and I'm trying to make the LEDs light up after another with the rlf(rotate left) instruction.
I have written this code:
However when I run it only the LED on RB0 blinks. The others do not light up at all. What am I doing wrong?
Thanks for reading.
I have 5 LEDs on PORTB of a PIC and I'm trying to make the LEDs light up after another with the rlf(rotate left) instruction.
I have written this code:
Code:
#include "p16F870.inc"
; CONFIG
; __config 0x3F3A
__CONFIG _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _CP_OFF & _BOREN_OFF & _LVP_OFF & _CPD_OFF & _WRT_ALL
cblock 0x20
d1
d2
d3
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
clrf PORTB
BANKSEL TRISB
movlw b'11100000'
movwf TRISB
BANKSEL PORTB
rlf PORTB
call _delay_1s
rlf PORTB
call _delay_1s
rlf PORTB
call _delay_1s
rlf PORTB
call _delay_1s
rlf PORTB
call _delay_1s
GOTO MAIN
_delay_1s
movlw h'D0'
movfw d1
actualdelay
decfsz d1
goto actualdelay
return
END
However when I run it only the LED on RB0 blinks. The others do not light up at all. What am I doing wrong?
Thanks for reading.