I've the following code:
That works in an awkward way, I mean, when CD7SEG is called the following values are returned according to the value of CONTADOR:
When CONTADOR=1 ->"1". OK
When CONTADOR=2 ->""2. OK
When CONTADOR=3 ->"2".
When CONTADOR=4 ->"3".
When CONTADOR=5 ->"3".
When CONTADOR=6 ->"4".
When CONTADOR=7 ->"4".
When CONTADOR=8 ->"5".
After this the program stops recognizing that the button which allows to jump to INCF CONTADOR,F is being pressed and the program cannot be executed properly anymore.
Any idea of what might be happening? It's pretty strange that the code works right for the first two numbers, and later it doesn't work.
Thanks.
Code:
LIST p=18F4620 ;Tipo de PIC
#include <p18F4620.inc>
; CONFIG DEBUG = ON
CONFIG OSC = INTIO67
;**************************************************************
;Define la posición del resultado
CONTADOR EQU 0x22
;************************************************************
ORG 0x0000 ;Comando que indica al Ensamblador
;la dirección de la memoria de programa
;donde situar la siguiente instrucción
;**************************************************************
MOVLW 0x06
MOVWF ADCON1
MOVLW 0x10
MOVWF TRISA
MOVLW 0x00
MOVWF TRISC
MOVLW 0x3F
MOVWF PORTC
INICIO CLRF CONTADOR
P1 BTFSC PORTA,4
GOTO P1
P0 BTFSS PORTA,4
GOTO P0
INCF CONTADOR,F
MOVLW 0xA
SUBWF CONTADOR,W
BTFSC STATUS,C
CLRF CONTADOR
MOVF CONTADOR,W
CALL CD7SEG
MOVWF PORTC
GOTO P1
CD7SEG
ADDWF PCL, F
retlw 06h
retlw 5bh
retlw 4fh
retlw 66h
retlw 6dh
retlw 7dh
retlw 07h
retlw 7fh
retlw 67h
retlw 3fh
END
That works in an awkward way, I mean, when CD7SEG is called the following values are returned according to the value of CONTADOR:
When CONTADOR=1 ->"1". OK
When CONTADOR=2 ->""2. OK
When CONTADOR=3 ->"2".
When CONTADOR=4 ->"3".
When CONTADOR=5 ->"3".
When CONTADOR=6 ->"4".
When CONTADOR=7 ->"4".
When CONTADOR=8 ->"5".
After this the program stops recognizing that the button which allows to jump to INCF CONTADOR,F is being pressed and the program cannot be executed properly anymore.
Any idea of what might be happening? It's pretty strange that the code works right for the first two numbers, and later it doesn't work.
Thanks.
Last edited: