Need PIC help, Please.

Thread Starter

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

Attachments

ErnieM

Joined Apr 24, 2011
8,377
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.
 

atferrari

Joined Jan 6, 2004
4,770
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.
 
Top