portb input problems


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

    Default portb input problems

    i cant get my portb pins working as inputs, any help?

    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
    
    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
    
    
    
    
    
    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
    goto loopa
    
    loopkeypad:
    if num1=0 then 
    hour=1
    endif
    goto loopkeypad
    
    
    
    
    
    
    
    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
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: portb input problems

    Code:
    ampm var portb.7
    trisb=%11111110
    Making "ampm" an input.

    But then you are writing to "ampm" as an output.
    Code:
    ampm=1
    Dave
    Always wear safety glasses while programming.

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