Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need the tail of 6 and 9

Status
Not open for further replies.

manojsoorya

Member
Hi all

I have a code for a digital Clock. I need the tail of 6 and 9. This is the code I have. But I dont know where to made the change to get the tail...
Code:
#include "p16f676.inc"

    __CONFIG _WDT_OFF & _XT_OSC & _CP_OFF & _MCLRE_OFF

temp                EQU        0x20
w_temp                EQU     0x21        ; variable used for context saving
status_temp            EQU        0x22        ; variable used for context saving   

        ORG     0
        GOTO    Start

        ORG     0x004             ; interrupt vector location
        movwf   w_temp            ; save off current W register contents
        movf    STATUS,w          ; move status register into W register
        movwf    status_temp       ; save off contents of STATUS register

; isr code can go here or be located as a call subroutine elsewhere

        incf    ms,F
        movlw    .225
        xorwf    ms,w
        btfss    STATUS,Z
        goto    $+3
        clrf    ms
        incf    count,F
        bcf        INTCON,T0IF   

        movf    status_temp,w     ; retrieve copy of STATUS register
        movwf    STATUS            ; restore pre-isr STATUS register contents
        swapf   w_temp,f
        swapf   w_temp,w          ; restore pre-isr W register contents
        retfie                    ; return from interrupt

        cblock     0x23
        d1
        d2
        d3
        d4
        temp1
        digit1
        digit2
        digit3
        digit4
        digit5
        digit6
        tempA
        count
        secdigit1
        secdigit2
        c1
        c2
        c3
        ms
        second
        endc

;----------------------------------------------------------------------
Initialize

        bcf        STATUS,RP0
        movlw    B'00000111'    ;to make RA0,RA1,RA2 ; test manoj B'00000111'
                            ;not comparator
        movwf    CMCON   
        clrf    PORTA
        bsf        STATUS,RP0
        movlw    B'00111000'
        movwf    TRISA   
        bcf        STATUS,RP0
        clrf    PORTC
        bsf        STATUS,RP0
        movlw    B'00000000'
        movwf    TRISC
       
        bcf        OPTION_REG,T0CS        ;configure the TMR0
        bcf        OPTION_REG,PSA
        bsf        OPTION_REG,0
        bsf        OPTION_REG,1
        bcf        OPTION_REG,2
        bsf        INTCON,T0IE
        bsf        INTCON,GIE
        bcf        STATUS,RP0            ;end       
        return
;-------------------------------------------------------------------
increment_digits
        incf    secdigit1,f
        movlw    .10
        xorwf    secdigit1,w
        btfss    STATUS,Z
            return
        clrf    secdigit1
        incf    secdigit2,f
        movlw    .6
        xorwf    secdigit2,w
        btfss    STATUS,Z
            return
        clrf    secdigit2
increment_min
        incf    digit1,f
        movlw    .10
        xorwf    digit1,w
        btfss    STATUS,Z
            return
        clrf    digit1
        incf    digit2,f
        movlw    .6
        xorwf    digit2,w
        btfss    STATUS,Z
            return
        clrf    digit2
increment_hour
        incf    digit3,f
        movlw    .1
        xorwf    digit4,w
        btfsc    STATUS,Z
        goto    check_12hour
        movlw    .10
        xorwf    digit3,w
        btfss    STATUS,Z
              return
        clrf    digit3
        incf    digit4,f
              return
check_12hour
        movlw    .3
        xorwf    digit3,w
        btfss    STATUS,Z
            return
        movlw    1h
        movwf    digit3
        clrf    digit4
        return
;---------------------------------------------------------------
dec_digits
        movlw    0x00
        xorwf    digit1,w
        btfsc    STATUS,Z
        goto    $+3
        decf    digit1,f
        return

        movlw    0x00
        xorwf    digit2,w
        btfsc    STATUS,Z
        return
        decf    digit2,f
        movlw    0x09
        movwf    digit1
          return   
;------------------------------------------------------------           
delay1ms
            movlw    3h
            movwf    d1               
            movlw    1h
            movwf    d2           
loopd2        decfsz    d2,f
            goto    loopd2
            decfsz    d1,f
            goto    loopd2
                return
;---------------------------------------------------------------
Display_out

            movlw    B'00000100'
            andwf    PORTA,F
            movlw    B'00000000'
            iorwf    PORTA,F           
            bsf        PORTC,5            ;digit1
            bcf        PORTC,4            ;digit2
            movlw    B'11110000'
            andwf    PORTC,F
            movf    digit1,w
            iorwf    PORTC,f
            call    check_button
            call    delay1ms

            movlw    B'00000100'
            andwf    PORTA,F
            movlw    B'00000000'
            iorwf    PORTA,F   
            bcf        PORTC,5            ;digit1
            bsf        PORTC,4            ;digit2
            movlw    B'11110000'
            andwf    PORTC,F
            movf    digit2,w
            iorwf    PORTC,f
            call    check_button
            call    delay1ms

            movlw    B'00000100'
            andwf    PORTA,F
            movlw    B'00000010'
            iorwf    PORTA,F   
            bcf        PORTC,5            ;digit1
            bcf        PORTC,4            ;digit2
            movlw    B'11110000'
            andwf    PORTC,F
            movf    digit3,w
            iorwf    PORTC,f
            call    delay1ms

            movlw    B'00000100'
            andwf    PORTA,F
            movlw    B'00000001'
            iorwf    PORTA,F   
            bcf        PORTC,5            ;digit1
            bcf        PORTC,4            ;digit2
            movlw    B'11110000'
            andwf    PORTC,F
            movf    digit4,w
            iorwf    PORTC,f
            call    delay1ms
display_RA2
            movf    tempA,w
            iorwf    PORTA,F
            call    delay1ms
                return
;----------------------------------------------------------------------
check_increment
        movlw    1h
        xorwf    count,w
        btfss    STATUS,Z
        return
        clrf    count
        call    increment_digits
        return
;----------------------------------------------------------------------
second_check
        movlw    .112
        subwf    ms,w
        btfss    STATUS,C
        goto    $+3
        bcf        tempA,2
        return
        bsf        tempA,2
        return
;---------------------------------------------------------------
check_button
            btfsc    PORTA,3
            return
            call    delay1ms
            btfsc    PORTA,3
            return
            call    delay1ms
            btfss    PORTC,4
            goto    check_min
            call    delay1ms
            btfss    PORTC,4
            goto    check_min
            call    delay1ms
            bcf        INTCON,GIE
            call    increment_hour
loop_increment_hour
            btfss    PORTA,3
            goto    loop_increment_hour
            call    delay1ms
            btfss    PORTA,3
            goto    loop_increment_hour
            call    delay1ms
            clrf    count
            bsf        INTCON,GIE
            return
check_min
            btfss    PORTC,5
            return
            call    delay1ms
            btfss    PORTC,5
            return
            call    delay1ms
            bcf        INTCON,GIE
            call    increment_min
loop_increment_min
            btfss    PORTA,3
            goto    loop_increment_min
            call    delay1ms
            btfss    PORTA,3
            goto    loop_increment_min
            call    delay1ms
            clrf    count
            bsf        INTCON,GIE
            return
;---------------------------------------------------------------
Start
            call     Initialize
            clrf    digit1
            clrf    digit2
            clrf    digit3
            clrf    digit4
            clrf    ms
            clrf    tempA
            clrf    count
            clrf    secdigit1
            clrf    secdigit2           
main                       
            call    check_increment
            call    second_check
            call    Display_out
            goto    main
            END
 
Here are the Hex values for the seven segment alphanumeric shapes.
retlw 0x3f ; code for 0, bit 7 is the dot. Common cathode. Invert values then clr bit 7 (dot) for common anode.
retlw 0x06; 1
retlw 0x5b; 2
retlw 0x4f ;3
retlw 0x66 ;4
retlw 0x6d ;5
retlw 0x7d ;6
retlw 0x07 ;7
retlw 0x7f ;8
retlw 0x67 ;9
retlw 0x77 ;A
retlw 0x7c ;b
retlw 0x39 ;C
retlw 0x5e ;d
retlw 0x79 ;E
retlw 0x71 ;F
 
What's a tail???

Tail:
6-tail.png

No Tail:
6-notail.png
 
OH!!! I didn't know that's what they were... I always use the tail otherwise the 6 becomes a b..

With the code posted... It looks like the display out function is outputting a BCD value so the digits will be generated in hardware..... What chip drives the seven segment?
 
Hi all
Thanks for helping me. I check the circuit again and again. Last I found its come from Hardware. The circuit use 74LS47 IC. The 74LS47 has no tail for 6 and 9. So can you please provide a circuit for BCD to seven segment converter with the tail?


Thanks again

Reguard manoj soorya
 
I believe the SN74247 displays the digits with tails.

**broken link removed**
 
Hi Sir

Really I look for a cheap ( minimum component) 7 segment clock with Second blinking LED. I have the above code and the circuit. Its working good. but the number 6 and the 9 not seen good. Can you provide me a circuit with code for a digital clock with PIC IC like 16F676, 16F628A, 16F72, 16F73, 16F722, 16F84A, 16F876, 16F873, 16F886, 16F870, 16F876A, 18F2550, 16F913, 16F88 and some Atmega chips and Atmel Chip in my collection.

Thanks for the valuable reply Sir......

God bless you

Reguard Manoj Soorya
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top