hello users
i have problem enable watchdog timer.
in mij main.cpp have added ->
then have created watchdog.cpp , watchdog.h
this watchdog.h
this watchdog.cpp
and last: code->
but question how enable watchdog timer??
the antser not just: put watchdogenable(10); in it
can me?
i have problem enable watchdog timer.
in mij main.cpp have added ->
code: [select]
int main( void )
{
/*++*/ watchdogsetup();
init();
initvariant();
delay(1);
then have created watchdog.cpp , watchdog.h
this watchdog.h
code: [select]
#ifndef _watchdog_
#define _watchdog_
#include <stdint.h>
// watchdog functions
/*
* \brief enable watchdog specified timeout. should called once.
*
* \param timeount in milliseconds.
*/
void watchdogenable (uint32_t timeout);
/*
* \brief disable watchdog timer. should called once.
*
*/
void watchdogdisable (void);
/*
* \brief reset watchdog counter.
*
*/
void watchdogreset (void);
/*
* \brief watchdog initialize hook. function called init(). if user not provide
* function, default action disable watchdog.
*/
void watchdogsetup (void);
#endif /* _watchdog_ */
this watchdog.cpp
code: [select]
#include <chip.h>
#include "watchdog.h"
void watchdogenable (uint32_t timeout)
{
/* assumes slow clock running @ 32.768 khz
watchdog frequency therefore 32768 / 128 = 256 hz */
timeout = timeout * 256 / 1000;
if (timeout == 0)
timeout = 1;
else if (timeout > 0xfff)
timeout = 0xfff;
// timeout = wdt_mr_wdrsten | wdt_mr_wdrproc | wdt_mr_wdv(timeout) | wdt_mr_wdd(timeout);
timeout = wdt_mr_wdrsten | wdt_mr_wdv(timeout) | wdt_mr_wdd(timeout);
wdt_enable (wdt, timeout);
}
void watchdogdisable(void)
{
wdt_disable (wdt);
}
void watchdogreset(void)
{
wdt_restart (wdt);
}
extern "c"
void _watchdogdefaultsetup (void)
{
wdt_disable (wdt);
}
void watchdogsetup (void) __attribute__ ((weak, alias("_watchdogdefaultsetup")));
and last: code->
code: [select]
void setup() {
serial.begin(9600);
}
void loop() {
serial.println ("i need see more ones know the watchdog timer enabled");
while (1);
}
but question how enable watchdog timer??
the antser not just: put watchdogenable(10); in it
can me?
the answer is: don't. longer implausible answer go in time , slap whoever disabled watchdog timer in arduino core library. longer , viable answer go arduino core library , modify not disable watchdog timer. see, can set watchdog once on microprocessor. after ignores changes. so, once disabled cannot enable it. once enable @ speed believe cannot change speed or disable it. presumably no programming mistake can mess watchdog it's annoying.
Arduino Forum > Products > Arduino Due (Moderator: fabioc84) > Watchdog DUE
arduino
Comments
Post a Comment