• AVR Freaks

Hot!PIC16f676 timer1 interrupt get stuck with port A output PIN

Author
nand1979
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2018/06/19 07:37:51
  • Location: 0
  • Status: offline
2020/01/22 06:44:21 (permalink)
1 (1)

PIC16f676 timer1 interrupt get stuck with port A output PIN

The problem got solved!! Thanks
post edited by nand1979 - 2020/01/22 07:46:14
#1

3 Replies Related Threads

    pcbbc
    Super Member
    • Total Posts : 1507
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: PIC16f676 timer1 interrupt get stuck with port A output PIN 2020/01/22 07:33:24 (permalink)
    +1 (1)
    There's no way toggling a port bit can cause a hang, unless something else is at play.
    So you need to look at something else other than your code.
    What is connected to RA4 externally?

    Maybe if you paired your code down to the minimum necessary to demonstate the problem we might be able to see the wood for the trees (or find the problem)...
     
    #include <stdio.h>
    #include <stdlib.h>

    Why include things you aren't using?
     
    #define sensTop PORTAbits.RA1
    #define sensMid PORTAbits.RA0
    #define sensSmp PORTAbits.RA5
    //#define PORTAbits.RA3
    #define ledFlo PORTAbits.RA4
    #define sensFlo PORTAbits.RA2
    //#define RA0 PORTCbits.R0
    #define sensOut PORTCbits.RC1
    #define relay PORTCbits.RC2
    #define ledSmp PORTCbits.RC3
    #define ledMid PORTCbits.RC4
    #define ledTop PORTCbits.RC5

    Why define loads of things you aren't using?

    TRISA = 0B00101111; // RA0 & RA1 set as input.

    And a load of other pins it would seem?

    ANSEL = 0B00000000; // Let ANS0 & ANS1 be analog input

    Nope.
     
    INTCON = 0B01100000;//enable timer 0

    Interupt enable, not timer.  And PEIE enabled for some reason?
     
    T1CON = 0B001100001;

    Usually best to set up timer before enabling interrupts.
    And no comment, so what timer mode you intended here.
     
    INTCONbits.GIE=0;
    INTCONbits.T0IE=0;
    INTCONbits.INTE=0;
    INTCONbits.RAIE=0;
    IOCA=0;
    INTCONbits.PEIE=1;
    PIE1bits.TMR1IE=1;
    INTCONbits.GIE=1;

    Why?  You already set lots of these in Initialize?
     
    //GIE=0;

    You've commented it out, but do not change GIE in an ISR.
     
    PORTCbits.RC3^=1;
    PORTCbits.RC4^=1;
    PORTCbits.RC5^=1;
    PORTAbits.RA4^=1;//this line makes the program stuck/hang ...

    What is connected to RA1 externally?
    Also you may have RMW issues.  Use a more modern PIC with LATx registers.
     
    while(1){
    _nop();
    }

    No need for a nop here, but I suppose it makes no difference.
     
    return;

    Not that this is reachable, but you do not need a return here.
    Where are you going to "return" to exactly?
     
    Probalby loads of other issues also.  Sorry, there were so many bad comments and supurleous code I gave up locking after a while.
     
    And PLEASE: Learn to use [​code]//code tags[​/code] around your code when posting:
    //code tags

    #2
    dilawar
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2019/04/25 12:39:02
    • Location: 0
    • Status: offline
    Re: PIC16f676 timer1 interrupt get stuck with port A output PIN 2020/01/22 07:39:25 (permalink)
    0
    please write the c -codes simple and clear for understanding and solving the problem
    visit the link for using timer zero of pic16f676;
    https://www.youtube.com/watch?v=2cdz23LEi6I
     
    #3
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC16f676 timer1 interrupt get stuck with port A output PIN 2020/01/22 13:02:12 (permalink)
    +1 (1)
    nand1979
    The problem got solved!! Thanks


    Please do NOT go and remove your question after you've started getting answers.
    That just wastes everyone's time.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5