• AVR Freaks

Help with timer 1 and/or ccp1

Author
davea
Junior Member
  • Total Posts : 111
  • Reward points : 0
  • Joined: 2016/01/28 13:12:13
  • Location: 0
  • Status: offline
2019/05/24 15:16:41 (permalink)
0

Help with timer 1 and/or ccp1

PIC16(L)F15313/23
timer 1 using LFINTOSC (31.5 KHz) ISR disabled, period = 0 (free running 16 bit timer)
FOSC @ 250 Khz
ccp1 set for 25 Ms
I have tried everything I could think of to fix
any help would be great
thanks David  
 
void CCP1_CompareISR(void) {
   CCPR1H += 3; // 25 Ms
   CCPR1L = 0;

    FLAGbits.DO_25Ms = 1;

    if(LATAbits.LATA4){LATAbits.LATA4 = 0;}else{LATAbits.LATA4 = 1;} // Oscope shows signal

    if (++S_mod > 40) {
        S_mod = 0;
        FLAGbits.AT_1S = 1;
    }
    PIR6bits.CCP1IF = 0;
}

 
 
 

Attached Image(s)

#1

6 Replies Related Threads

    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11175
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Help with timer 1 and/or ccp1 2019/05/24 15:23:38 (permalink)
    0
    Do you have the watchdog timer enabled?
    #2
    davea
    Junior Member
    • Total Posts : 111
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: 0
    • Status: offline
    Re: Help with timer 1 and/or ccp1 2019/05/24 15:26:09 (permalink)
    0
    yes @ 500Ms
    and there are NO resets
    also it happens a little faster then 1 Hz
    post edited by davea - 2019/05/24 15:35:16
    #3
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11175
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Help with timer 1 and/or ccp1 2019/05/24 16:25:45 (permalink)
    0
    How do you know there are no resets?  Why in the word would you try to debug this with the WDT enabled?
    #4
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11175
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Help with timer 1 and/or ccp1 2019/05/24 16:29:01 (permalink)
    0
    What happens when CCPR1H overflows?  You're incrementing by a number that doesn't divide evenly into 256, so that may cause issues.
     
    #5
    NorthGuy
    Super Member
    • Total Posts : 5428
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Help with timer 1 and/or ccp1 2019/05/24 16:45:14 (permalink)
    0
    1Hz is approximately when you set S_mod to 0, so I guess this is what causing the problem. The code on your monitor looks a little bit too small at the distance, so it's hard for me to see what's the exact mechanism.
    #6
    davea
    Junior Member
    • Total Posts : 111
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: 0
    • Status: offline
    Re: Help with timer 1 and/or ccp1 2019/05/24 17:08:20 (permalink)
    0
    SORRY for the trouble
    I found the problem
    it was ME
    its hard to debug with only 1 test point
    it was a leftover LATAbits.LATA4
    that I missed
    thanks all
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5