Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] how could i fix this assembly code??

Status
Not open for further replies.

chipo312

Newbie level 2
Joined
Dec 17, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
12
Code:
INCLUDE <P16F877A.INC>

COUNT_1         EQU     0X20
COUNT_2         EQU     0X21
CNT_RTC         EQU     0X22
DISP1           EQU     0X23
DISP2           EQU     0X24
DISP3           EQU     0X25
DISP4           EQU     0X26
NUM             EQU     0X27
TIME            EQU     0X28

                ORG     0
MAIN            BSF     STATUS,RP0
                MOVLW   B'00010100'
                MOVWF   OPTIONR
                MOVLW   B'00000000'
                MOVWF   TRISC
                MOVLW   B'00000000'
                MOVWF   TRISD
                BCF     STATUS,RP0

                CLRF    PORTC
                CLRF    PORTD
                CLRF    DISP1
                CLRF    DISP2
                CLRF    DISP3
                CLRF    DISP4

SIJAK           CALL    DISPLAY

DIGIT4          CALL    SEC

                INCF    DISP4
                MOVF    DISP4,W
                XORLW   B'00001010'
                BTFSS   STATUS,ZF
                GOTO    DIGIT3
                CLRF    DISP4
                INCF    DISP3

DIGIT3          MOVF    DISP3,W
                XORLW   B'00000110'
                BTFSS   STATUS,ZF
                GOTO    DIGIT2
                CLRF    DISP3
                INCF    DISP2

DIGIT2          MOVF    DISP2,W
                XORLW   B'00001010'
                BTFSS   STATUS,ZF
                GOTO    DIGIT1
                CLRF    DISP2
                INCF    DISP1

DIGIT1          MOVF    DISP1,W
                XORLW   B'00000110'
                BTFSS   STATUS,ZF
                GOTO    DISP_RTN
                CLRF    DISP1
                NOP

DISP_RTN        CALL    DISPLAY
                GOTO    DIGIT4

WAIT            MACRO   TIME
                MOVLW   (TIME/5)-1
                MOVWF   NUM
                CALL    WAIT5U
                ENDM

WAIT5U          NOP
                NOP
                DECFSZ  NUM,F
                GOTO    WAIT5U
                RETLW   0

SEC             CLRF    RTCC
                MOVLW   .237
                MOVWF   CNT_RTC
                BCF     STATUS,CF

LOOP1           BTFSS   RTCC,7
                GOTO    LOOP1
                CLRF    RTCC

                CALL    DISPLAY

                DECFSZ  CNT_RTC
                GOTO    LOOP1
                RETURN

DISPLAY
                MOVF    DISP4,W
                CALL    FND_TABLE
                MOVWF   PORTD
                BSF     PORTC,3
                WAIT    .20
                CLRF    PORTC

                MOVF    DISP3,W
                CALL    FND_TABLE
                MOVWF   PORTD
                BSF     PORTC,2
                WAIT    .20
                CLRF    PORTC

                MOVF    DISP2,W
                CALL    FND_TABLE
                MOVWF   PORTD
                BSF     PORTC,1
                WAIT    .20
                CLRF    PORTC

                MOVF    DISP1,W
                CALL    FND_TABLE
                MOVWF   PORTD
                BSF     PORTC,0
                WAIT    .20
                CLRF    PORTC
                RETURN

FND_TABLE
                ADDWF   PCL
                RETLW   B'11000000'  ;0
                RETLW   B'11111001' ;1
                RETLW   B'10100100';2
                RETLW   B'10110000';3
                RETLW   B'10011001';4
                RETLW   B'10010010';5
                RETLW   B'10000010';6
                RETLW   B'11011000';7
                RETLW   B'10000000';8
                RETLW   B'10010000';9
                RETLW   B'11000000';0
                RETURN

                END




digital clock.jpg


7segment is not working ---------------where is wrong???


simulation program was proteus
[ 0 0 ] [ 0 0 ]
min sec
 
Last edited by a moderator:

Zip and attach both MPASM project files and Proteus file.
 
Zip and post complete MPLAB MPASM project files.

The logic is like this.

Create an ISR using Timer which interrupts every 5 ms and in ISR use a counter which counts from 0 to 4 and loops. This counter is incremented on each interrupt and when it reaches value greater than 3 it is reset to 0. Based on the value of this counter assign mask(digit) value to each & segment display. In main loop break the number into digits 0, 1, 2, and 3 and loop infinitely. All the SSD work is done in ISR. This way you don't need delays and your display will not flicker. I will find some time this weekend and I will write a code for you.

- - - Updated - - -

Google for "7 Segment PIC ASM Code" and check the first two links that you get.
 
Last edited:
Miss the fuse... And what is OPTIONR???
To see correct way is simulate in minor frequency because the pov and time response for simulator.
 
I don't think your code is going to assemble without Errors because RTCC was Declared either as a Variable or Defined.
Am going to edit your code and send it back to you.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top