Menu

Odd Behaviour

Help
MBB
2012-07-31
2013-05-30
  • MBB

    MBB - 2012-07-31

    I'm using a PIC 16F1876.  In a subroutinre I have the following code.

    If T_Sel = 1 then
    AnemNS:
    BTFSC PORTA,0; Rec_1
    Goto Anem1b
    A_Cnt = A_Cnt + 1; # of times Inst. Cycles repeated
    BTFSC STATUS, C; Check fo Carry Bit
    Goto Anem1B
    Goto AnemNS
    End If

    '
    If T_Sel = 2 then
    AnemSN:
    BTFSC PORTA,1; Rec_2
    Goto Anem1b
    A_Cnt = A_Cnt + 1
    BTFSC STATUS, C
    Goto Anem1B
    Goto AnemSN
    End If

    '
    If T_Sel = 3 then
    AnemEW:
    BTFSC PORTB,1; Rec_3
    Goto Anem1b
    A_Cnt = A_Cnt + 1
    BTFSC STATUS, C
    Goto Anem1B
    Goto AnemEW
    End If

    '
    If T_Sel = 4 then
    AnemWE:
    BTFSC PORTB,2; Rec_4
    Goto Anem1b
    A_Cnt = A_Cnt + 1

    'BTFSC STATUS, C
    'Goto Anem1B
    Goto AnemWE
    End If

    '
    Anem1b:

    The above code works.  If I remove the comments marks in the T_Sel = 4 section from:

             BTFSC STATUS, C
    Goto Anem1B

    GCB still compiles the code with no errors and I can download it to the PIC BUT only the code under the T_Sel = 1 section  runs before the program freezes.

    Does anyone know how to fix this?

     
  • MBB

    MBB - 2012-07-31

    In the above make that a PIC 16F876.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.