#### Pinnacle187

Joined Apr 28, 2016
16
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)
Code:
;Pre-processor Directives
;----------------------------------------

LIST   P=16F88
INCLUDE  P16F88.INC
__CONFIG   _CONFIG1,3F61
__CONFIG  _CONFIG2,3FFC

; Definitions (#Define)
;----------------------------------------
CBLOCK
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

START
BTFSS  PORTA,0
GOTO  START
CALL  SIETE_SEGMENTOS
MOVWF  DISPLAY
CALL  RETARDO

CONTAR
MOVLW  .10
BTFSC  STATUS,C
GOTO  START
CALL  SIETE_SEGMENTOS
MOVWF  DISPLAY
CALL  RETARDO
GOTO  CONTAR

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
edited by moderator: code tags inserted, deleted COLOR tags

#### Attachments

• 1.5 KB Views: 4

#### ErnieM

Joined Apr 24, 2011
8,011
Hi Pinnacle, welcome to the forums.

(In the future please use code tags to post code so the formatting stays. Easier than looking to your link, especially for those of us using devices not a PC to view.)

What does your code do incorrectly? How sure of the hardware are you?

Before writing any code can you make a flowchart of how the code should flow? Simple words outlining steps is fine, don't need all the graphics. Basically it is a pseudo code version to outline what steps you see as necessary.

#### TheButtonThief

Joined Feb 26, 2011
236
Are you asking for help on a homework/coursework assignment?

#### atferrari

Joined Jan 6, 2004
3,636
The first button controls the power, right? If so, it is not involved with the code.

Question: have you got any simple working program for that micro? Once you get one, things should be really easier because a proper flow diagram as already suggested will help.

The 8 pins display, is it a port?

Aprendé a caminar antes de salir corriendo.