Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] PIC18F, change the watchdog wake up interval

Status
Not open for further replies.

alexxx

Advanced Member level 4
Advanced Member level 4
Joined
Apr 17, 2011
Messages
1,013
Helped
273
Reputation
552
Reaction score
270
Trophy points
1,383
Location
Greece
Activity points
7,936
In my application, I have the watchdog with 131 seconds timeout. The PIC wakes up, does some stuff and goes back to sleep. Under some circumstances, I would like to wake up not after 131 seconds, but after 10 seconds. I searched and came up to the conclusion that this is impossible to do with the watchdog, because I cannot change watchdog's prescaler during runtime.

It is not easy to add extra external components because the pcb is full. On the other hand, I cannot stay awake for 10 seconds, neither use an idle mode instead of sleep, because I need to have only some uA of consumption (<50 uA). So is there any way to achieve this without external components added?

I am using PIC18F25K20 and mplabX.

Thanks in advance
 

I am not sure but is it possible to give some external interrupt after 10 seconds? You can configure a timer for the defined time and toggle the port and give the feedback to the interrupt. It is just my idea.
 
  • Like
Reactions: alexxx

    alexxx

    Points: 2
    Helpful Answer Positive Rating
The usual solution is to configure the watchdog wakeup to the faster rate (e.g. 8 sec) and skip the wake events in software if appropriate. Additional power consumption is almost negligible.
 
  • Like
Reactions: alexxx

    alexxx

    Points: 2
    Helpful Answer Positive Rating
The WDT prescalar bits are in CONFIG2H on that MCU. Check out Section 23.1 of the data sheet for how to write to this part of the memory.
However, you had better be very careful doing this as you can easily mess up the config settings for the device such that a complete re-program is the only way back.
Susan
 
  • Like
Reactions: alexxx

    alexxx

    Points: 2
    Helpful Answer Positive Rating
I think the FVM's advice (see above) is the good solution.

Read this thread on the Microchip forum:
https://www.microchip.com/forums/m696216.aspx#696477
It gives also an asm example, but says this:
Actually the WDT postscaler can be changed on-the-fly at runtime, but it's not a good idea to write the same flash location too often as flash memory cell endurance is 10K cycles.
 
  • Like
Reactions: alexxx

    alexxx

    Points: 2
    Helpful Answer Positive Rating
Thank you all, I followed the suggestion in post #3 and it worked just fine. It is kind of annoying not to have the ability to change the watchdog during runtime, but this technique can be a solution in this specific problem. Writing the configuration bits in flash is not an option for this application, because the flash will be written 10K times within a couple of years.
 

It is kind of annoying not to have the ability to change the watchdog during runtime
Consider it as fail-safe feature to prevent inadvertent deactivation of the watchdog. Similarly configuration flash should be protected against self-programming.
 
  • Like
Reactions: alexxx

    alexxx

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top