AMPM stoped working


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2011
    Posts
    19

    Default AMPM stoped working

    While working on this clock my ampm stoped working and i dont know what i changed to do this. Can one of you guys help me in pointing out a problem in my code relating to the ampm.(16f887)

    Code:
    digit1 var portd.0
    digit2 var portd.1
    digit3 var portd.2
    digit4 var portd.3
    digit5 var portd.4
    digit6 var portd.5
    cnt var word
    digit var byte
    pattern var byte
    i var word
    first var byte
    second var byte 
    third var byte
    fourth var byte
    fifth var byte
    sixth var byte
    mills var word
    seconds var byte
    mins var byte
    hour var byte
    ampm var portb.7
    parker var byte
    num1 var portb.6
    num2 var portb.5
    num3 var portb.4
    num4 var portb.3
    num5 var portb.2
    num6 var portb.1
    num7 var portb.0
    num8 var portc.4
    num9 var portc.5
    num0 var portc.6
    
    seconds=45
    mins=59
    hour=11
    mills=1
    cnt=0
    ANSEL=0
    
    INTCON=%10100000
    OPTION_REG=%00000000
    TMR0=6
    on interrupt goto isr
    INTCON=%10100000  
    
    trise=1
    trisa=0
    trisd=0
    trisb=%11111110
    trise=1
    trisc=1
    ampm=1
    parker=0
    portb=1
    
    
    
    
    
    loopa:
    if portc.3=1 then
        mills=mills+1000
        while portc.3=1
        wend
        endif
    if mills>59 then
        mills=0
        seconds=seconds+30
        endif
    if seconds>59 then
        seconds=0
        mins=mins+1
        endif
    if mins>59 then
        mins=0
        hour=hour+1
        endif
    if hour>11 then
        hour=1 
      if parker=0 then
            ampm=0
            parker=1
        else
         parker=0               
            ampm=1
        endif
        endif
        if num1=0 then
        goto loopkeypad
         endif
         goto loopa
    
    loopkeypad:
    for i=0 to 20
    pause 1
    next i
    i=1
    while i=1
    hour=0
    seconds=0
    mins=0
    wend
    if num1=0 then i=0
    for i=0 to 20
    pause 1     
    next i
    goto loopa
    
    
    disable
    isr:TMR0=6
    digit=hour dig 1
    lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern
    porta=pattern
    digit6=1
    pauseus 500
    digit6=0
    
    digit=hour dig 0
    lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern
    porta=pattern
    digit5=1
    pauseus 500
    digit5=0
    
    digit=mins dig 1
    lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern
    porta=pattern
    digit4=1
    pauseus 500
    digit4=0
    
    digit=mins dig 0
    lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern
    porta=pattern
    digit3=1
    pauseus 500
    digit3=0
    
    digit=seconds dig 1
    lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern
    porta=pattern 
    digit2=1
    pauseus 500
    digit2=0
    
    digit=seconds dig 0
    lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern
    porta=pattern
    digit1=1
    pauseus 500
    digit1=0
    cnt=cnt+1
    intcon.2=0
    resume 
    enable
    
    
    end

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: AMPM stoped working

    It seems like it should work, but I will ask these questions:

    On reset is ampm on?
    When you push portb.7 the first time does it turn off?

    If so, it appears you will need to press the portb.7 switch 1320 more times to get it to turn back on. Have you tried that?

    I don't see where anything increments your MILS variable other than portb.7. so no other variables will increment until you press the button. Maybe what you changed was how cnt affects the program?

    As a side note, even a few comments sprinkled around go a long way to help others debug your program
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts