Hi guys,
while toying around with a PIC16F690, I found it not looping over the carry flag when RLFing through the PORTC ports.
I'm somewhat new to PICs and kept scratching my head for an explanation.
The code is for a basic 8 LED chaser.
I've included some code where I manually clear and set the respective ports, to assure that all the LEDs are connected and working before entering the main loop. Upon entering the loop everything works fine, until RC7 should be activated. The LEDs stop there, so neither RC7, nor the carry flag is set.
Any hints on what causes this are greatly appreciated.
The code I'm using is as follows:
while toying around with a PIC16F690, I found it not looping over the carry flag when RLFing through the PORTC ports.
I'm somewhat new to PICs and kept scratching my head for an explanation.
The code is for a basic 8 LED chaser.
I've included some code where I manually clear and set the respective ports, to assure that all the LEDs are connected and working before entering the main loop. Upon entering the loop everything works fine, until RC7 should be activated. The LEDs stop there, so neither RC7, nor the carry flag is set.
Any hints on what causes this are greatly appreciated.
The code I'm using is as follows:
Rich (BB code):
list p=16f690 ; list directive to define processor
#include <P16F690.inc> ; processor specific variable definitions
__CONFIG _PWRTE_ON & _WDT_OFF & _XT_OSC
loops Equ 0x22
loops2 Equ 0x23
Init
BCF STATUS, RP0 ; Select Bank 2
BSF STATUS, RP1
CLRF ANSEL
BSF STATUS, RP0 ; Select Bank 1
BCF STATUS, RP1
MOVLW B'00000000' ; PortC all outputs
MOVWF TRISC
BCF STATUS, RP0 ; Select Bank 0
CLRF PORTC ; turn off all LEDs
; Emulate the running light for testing the LEDs
CALL Set1R
CALL Set2R
CALL Set3R
CALL Set4R
CALL Set5R
CALL Set6R
CALL Set7R
CALL Set8R
CLRF PORTC
; Now set the first pin and start looping
BSF PORTC, 0
Loop
CALL Wait
RLF PORTC, 1
NOP
goto Loop
;**********************************************************
; Manually setting the pins here
Set1R
bcf PORTC, 7
NOP
bsf PORTC, 0
CALL Wait
RETLW 0
Set2R
bcf PORTC, 0
NOP
bsf PORTC, 1
CALL Wait
RETLW 0
Set3R
bcf PORTC, 1
NOP
bsf PORTC, 2
CALL Wait
RETLW 0
Set4R
bcf PORTC, 2
NOP
bsf PORTC, 3
CALL Wait
RETLW 0
Set5R
bcf PORTC, 3
NOP
bsf PORTC, 4
CALL Wait
RETLW 0
Set6R
bcf PORTC, 4
NOP
bsf PORTC, 5
CALL Wait
RETLW 0
Set7R
bcf PORTC, 5
NOP
bsf PORTC, 6
CALL Wait
RETLW 0
Set8R
bcf PORTC, 6
NOP
bsf PORTC, 7
CALL Wait
RETLW 0
;**********************************************************
; Wait for 250 ms
Wait
movlw D'250'
movwf loops
Wai
movlw .110
movwf loops2
Wai2 nop ;
nop
nop
nop
nop
nop
decfsz loops2, F
goto Wai2
decfsz loops, F
goto Wai
retlw 0
end