BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:47 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Watchdog timer
PostPosted: Wed Oct 12, 2011 6:27 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Hi,

Is it possible to access the internal watchdog timer on the nano 8 and nano 28?

Thanks

Chris


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Wed Oct 12, 2011 6:34 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
its not a timer in the normal sense. If it times out it will reset but there is no register you can read to see how much time is left. All basic commands handle the watchdog timer themselves. Only if you use asm code do you need to worry about it. You would execute a clrwdt command to reset the timer so your code doesn't cause a reset.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Thu Oct 13, 2011 12:24 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Hi Nathan,

I am not worried about it, I want to use it.
What do you mean by " All basic commands handle the watchdog timer themselves"?
I didn't see any command on my manual (V2_1) talking about watchdog?

Thanks

Chris


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Sat Oct 15, 2011 2:13 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
The watch dog timer will timeout after ~18ms if a clrwdt command is not executed. The compiler qutomatically addes clrwdt commands so the user never has to do this if theri program is entirely written in basic. Some users use inline asm code to speed up sections of their program. If they spend more than 18ms in asm code without exectuing a clrwdt instruction the chip will reset.

Because the basic compiler handles the watchdog timer for basic code there is no basic comamnd to clear it. Only inline asm code needs it and clrwdt is an asm command. Asm coding is documented in PICmicro datasheets. It is an advanced feature and is assumed the user wanting to use it already knows PICmicro asm. We don't try to teach it.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Sun Oct 16, 2011 11:09 pm 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Let me see if I understood this right:
If the nano freeze or doesn't start executing the basic code in Basic, it should timeout and then reset after 18 ms?
The whatch dog is "automatic"?
If this is true, I assume it is true for all your microcontroller?

Thanks

Chris


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Mon Oct 17, 2011 10:03 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Well there is no way the basic code won't start(unless the chip was physically damaged). But if you add your own inline asm code that causes an infinite loop the watchdog timer will force a reset. In most cases a watchdog timer reset is a bad thing but if you see your program reseting and you have inline asm code then it could be because you aren't clearing the watchdog timer using clrwdt.

All Nano and Atom processors habe an active watchdog timer. All AtomPros do not use a watchdog timer(there is one we just don't use it). In my entire life the usefullness of the watchdog timer has been strictly for catching buggy asm code. Even then it's only usefull with certain types of buggy asm code(eg ones that cause infinite loops).

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Tue Oct 18, 2011 12:18 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
I have seen a lot of microcontroller not starting and I often use an external watchdog to make sure they start but maybe the internal watchdog are not for the same purpose.
As a mettre of fact, I am having the problem with a nano 8, I have to reset it manually to make it start running (and I didn't put an external watchdog on my lay out). It's why I was asking about internal watchdog to avoid redoing the lay out

Thanks for the explanation

Chris


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Tue Oct 18, 2011 9:32 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Thats not a watchdog, its a POR(power on resets). The Nanos, Atoms and AtomPros how PORs. A watchdog isn't going to fix a chip that isn't starting. Awatchdog timer is only to reset a chip that gets stuck(eg infinite loop).

I'd have to know more about your circuit to be able to guess what could be the problem causing your Nano not to run on power up but it has nothing to do with the watchdog timer.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Tue Oct 18, 2011 10:30 pm 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Ok
What do you mean by "The Nanos, Atoms and AtomPros how PORs."?

Thanks

Chris


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Tue Oct 18, 2011 10:47 pm 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Here is the electrical diagram of the PCB, in case you can help me.
Thanks

Chris


Attachments:
Schéma.pdf [257.69 KiB]
Downloaded 62 times
Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Wed Oct 19, 2011 9:07 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
1. A POR is a power on reset circuit. All our processors have them. What it does is hodl the chip in reset until the voltage has reached a minimum level when first plugged in.

2. I would recommend putting a pullup on the reset pin in your circuit. It looks like you are driving a motor? The internal pullup may not be strong enough to keep the chip from resetting because of noise form the motor.

3. Another possibility is your code could be the problem. Please post your code and I'll see if you have something in it that could cause ti to freeze up when it first starts.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Tue Nov 15, 2011 8:37 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Hi Nathan,

Sorry, I have been away for a while.
I will check your idea and keep you inform.

Thanks

Chris


Top
 Profile  
 
 Post subject: Re: Watchdog timer
PostPosted: Thu Feb 02, 2012 10:30 pm 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Hi Nathan,

You were right the problem was in the code.
I was using the command "sleep" and the nano wouldn't wake up
I am now using the command "pause" instead and everything is fine.

Thanks a lot

Chris


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO