Hey guys I'm having trouble writing a code for a project I have (I have to make a working circuit). I'm using a PIC16F88 and I'm trying to display numbers from 0 - 9 on a 8 pin display and I can't manage to do it, I have to write the code in assembler. The program has to consider 3 buttons: one that turns on the circuit, one that increases count, and one that decrease count, the delay between each number is 5 seconds.
This is what I have until now:
Contador = counter (it's in spanish)
edited by moderator: code tags inserted, deleted COLOR tags
This is what I have until now:
Contador = counter (it's in spanish)
Code:
;Pre-processor Directives
;----------------------------------------
LIST P=16F88
INCLUDE P16F88.INC
__CONFIG _CONFIG1,3F61
__CONFIG _CONFIG2,3FFC
; Definitions (#Define)
;----------------------------------------
CBLOCK
CONTADOR1
ENDC
TIMX EQU 0X21
TIMY EQU 0X22
TIMZ EQU 0X23
#DEFINE DISPLAY PORTB
;Initial direction in program memory
;----------------------------------------
ORG 0
;START
;-------------------------------------
PREINICIO
BSF STATUS,RP0
CLRF DISPLAY
BCF STATUS,RP0
CLRF CONTADOR1
START
BTFSS PORTA,0
GOTO START
CLRF CONTADOR1
MOVF CONTADOR1,W
CALL SIETE_SEGMENTOS
MOVWF DISPLAY
CALL RETARDO
CONTAR
INCF CONTADOR1,F
MOVLW .10
SUBWF CONTADOR1,W
BTFSC STATUS,C
GOTO START
MOVF CONTADOR1,W
CALL SIETE_SEGMENTOS
MOVWF DISPLAY
CALL RETARDO
GOTO CONTAR
ADDWF PCL,F
TABLA
RETLW B'01101111'
RETLW B'01111111'
RETLW B'00000111'
RETLW B'01111101'
RETLW B'01101101'
RETLW B'01100110'
RETLW B'01001111'
RETLW B'01011011'
RETLW B'00000110'
RETLW B'00111111'
RETURN
RETARDO
MOVLW .6
MOVWF TIMX
MOVLW .19
MOVWF TIMY
MOVLW .172
MOVWF TIMZ
DEL
DECFSZ TIMZ,F
GOTO DEL
DECFSZ TIMY,F
GOTO DEL
DECFSZ TIMX,F
GOTO DEL
NOP
RETURN
END
END
Attachments
-
1.5 KB Views: 4