• AVR Freaks

Hot!PIC18LF25K22

Author
Levi
New Member
  • Total Posts : 29
  • Reward points : 0
  • Joined: 2018/03/02 22:33:59
  • Location: 0
  • Status: offline
2019/10/23 06:52:08 (permalink)
0

PIC18LF25K22

I'm working with timers in pic18lf25k22 and trying to get 3min delay from timer0 using loops. But the maximum delay we are getting is 2min 11sec using any no.of timers using same program
Attached the following code..
 
#1

4 Replies Related Threads

    Mysil
    Super Member
    • Total Posts : 3476
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: PIC18LF25K22 2019/10/23 07:18:53 (permalink)
    +1 (1)
    Hi,
    Make sure that your program doesn't get shut down and restarted by the Watchdog Timer.
    Either by disabling the watchdog timer in configuration word,
    or by attending the watchdog timer in suitable interval.
     
        Mysil
    #2
    pcbbc
    Super Member
    • Total Posts : 1381
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: PIC18LF25K22 2019/10/23 09:00:07 (permalink)
    +2 (2)
    As Mysil says, check you do not have the WDT enabled.
     
    Also probably better to more the line...
    PIR1bits.TMRxIF = 0;

    ...to before this wait...
    while (INTCONbits.TMRxIF == 0);

    You want to make sure the flag is not set before waiting on it.
     
    I know you are turning the timer off after you have finished with it and clearing the flag, so it shouldn't get set again.  However best practice says you should make sure of initial conditions before doing something, rather than relying on them being set to defaults (the first time you do something) or on the value you set at the end of the previous routine (on subsequent iterations).
     
    Also you should probably consider using a timer with a hardware period register (PRx) if you looking for accurate timing, rather than manually reloading TMRxH/L.  See timers 2, 4 and 6.
    #3
    1and0
    Access is Denied
    • Total Posts : 9989
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC18LF25K22 2019/10/23 09:46:43 (permalink)
    +1 (1)
    GAYATHRI SIVAKUMAR
    I'm working with timers in pic18lf25k22 and trying to get 3min delay from timer0 using loops. But the maximum delay we are getting is 2min 11sec ...

    +1 on the watchdog timer, which if my memory is correct the maximum WDT timeout is 2 min 11 sec on that PIC device.
    #4
    ian_3k
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2015/11/10 01:18:28
    • Location: England
    • Status: offline
    Re: PIC18LF25K22 2019/10/25 08:31:22 (permalink)
    +1 (1)
    Have you considered using the code configurator to set up your timer and oscillator options. It is really a lot easier than setting up registers. By choosing the right clock frequency and timer pre-scaler, it will generate a callback function for you at exactly 180 seconds if that is what you want.
    I have a short video demo which might be helpful:
    https://www.youtube.com/watch?v=gMrrpvwcbtk
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5