parts-man73
New Member
This little bit of code I wrote as a practice while teaching myself assembly. I programmed the PIC, with options for watchdog off, and using the internal oscillator, and put in a solderless breadboard. I connected 8 LEDS with current limiting resistors on RB0-RB7. VSS is connected to ground, VDD connected to 5V, and pin 4 pulled to 5V with a 4.7k resistor.
I expected to see a "bit" to scroll across the LED's, then start again from the other side. and continue until the cows come home.
What I get is a few of the LEDS in the first nibble light up in order, then nothing out of the second nibble, and nothing repeats.
Is this a code error that I'm overlooking? Sorry about the formatting in the code, I guess a subquestion is, how are people attaching code so it looks nice?
Thank you,
Brian
INCLUDE "P16F628A.inc"
COUNT1 equ 20h
COUNT2 equ 21h
bsf STATUS,RP0 ;bank 1
clrf TRISB
bcf STATUS,RP0 ;bank 0
Start CLRF PORTB
movlw 01h ; load 00000001 in W
movwf PORTB ; then move w to portb
Loop call Delay ; delay routine
rrf PORTB,1 ; rotate bits right
goto Loop
Delay
Loop1 decfsz COUNT1,1
goto Loop1
decfsz COUNT2,1
goto Loop1
return
end
I expected to see a "bit" to scroll across the LED's, then start again from the other side. and continue until the cows come home.
What I get is a few of the LEDS in the first nibble light up in order, then nothing out of the second nibble, and nothing repeats.
Is this a code error that I'm overlooking? Sorry about the formatting in the code, I guess a subquestion is, how are people attaching code so it looks nice?
Thank you,
Brian
INCLUDE "P16F628A.inc"
COUNT1 equ 20h
COUNT2 equ 21h
bsf STATUS,RP0 ;bank 1
clrf TRISB
bcf STATUS,RP0 ;bank 0
Start CLRF PORTB
movlw 01h ; load 00000001 in W
movwf PORTB ; then move w to portb
Loop call Delay ; delay routine
rrf PORTB,1 ; rotate bits right
goto Loop
Delay
Loop1 decfsz COUNT1,1
goto Loop1
decfsz COUNT2,1
goto Loop1
return
end