johnnyquest
New Member
I have some code that appears to work fine while debugging and looking at all the registers but when I program the 16f628a it does not work.
The code displays the number 0 on one of four seven segment displays and rotates which display is on. I am driving common cathode leds directly so the led that is on is active low. I tried other programs to direct drive leds displaying the number 21 and it works fine. Please let me know what I am doing wrong.
LIST P=16f628a
ERRORLEVEL -302
include <p16f628a.inc>
TempC equ 0x20 ;temp general purpose regs
org 0
goto Start
Start
movlw 7
movwf CMCON
bsf STATUS,RP0
clrf TRISA ;make RA0-4 outputs
clrf TRISB ;make RB0-7 outputs
bcf STATUS,RP0 ;select page 0
clrf PORTA ;make all outputs low
clrf PORTB ; /
movlw b'0111' ;start with 1st display
movwf PORTA
UpdateDisplay
movf PORTA,W ;present sink value in w
movwf TempC ;save sink value in tempC
rrf TempC, F ;determine next sink value
btfsc STATUS,C ;c=1?
bsf TempC,3 ;no then reset MSD sink
movlw b'00111111'
movwf PORTB ;drive leds
movf TempC,W ;get sink value in w
movwf PORTA
goto UpdateDisplay
end
The code displays the number 0 on one of four seven segment displays and rotates which display is on. I am driving common cathode leds directly so the led that is on is active low. I tried other programs to direct drive leds displaying the number 21 and it works fine. Please let me know what I am doing wrong.
LIST P=16f628a
ERRORLEVEL -302
include <p16f628a.inc>
TempC equ 0x20 ;temp general purpose regs
org 0
goto Start
Start
movlw 7
movwf CMCON
bsf STATUS,RP0
clrf TRISA ;make RA0-4 outputs
clrf TRISB ;make RB0-7 outputs
bcf STATUS,RP0 ;select page 0
clrf PORTA ;make all outputs low
clrf PORTB ; /
movlw b'0111' ;start with 1st display
movwf PORTA
UpdateDisplay
movf PORTA,W ;present sink value in w
movwf TempC ;save sink value in tempC
rrf TempC, F ;determine next sink value
btfsc STATUS,C ;c=1?
bsf TempC,3 ;no then reset MSD sink
movlw b'00111111'
movwf PORTB ;drive leds
movf TempC,W ;get sink value in w
movwf PORTA
goto UpdateDisplay
end