Go Down

Topic: DUE Watchdog usage (Read 15556 times) previous topic - next topic

skaarj

#15
Apr 15, 2015, 05:58 pm Last Edit: Apr 15, 2015, 06:02 pm by skaarj
Allright, I have been digging for a few weeks so I will not post a stupid question in this topic.

I'm trying to modify a library written by some incompetents for a wireless networking shield - the FT1076M from futura electronics (open-electronics.org store). Those dudes just pretend the Sam3X controllers do not exist and in conclusion the library (MWifi) is written for the older avr architecture. The watchdog handling functions are included in avr/wdt.h. People pay money and are deceived because they lack the proper documentation so I wish to fix this problem.

As I wish to solve this for arduino due, first I would like to compile a sketch with some basic WDT functions.
Bur surprise - I cannot include the sam3x wdt.h because it is nowhere to be found in the include search path. And I am stuck in windows - in BSD it is easy to modify the include path.

Now, I respectfully ask you for help.  A sketch has a setup() and a loop() but I see nothing on this post. What are you compiling and what are you including? There is nothing clear. Before the setup, the sketch can include stuff.  #include <wdt.h> does not work (unable to locate wdt.h) and the avr/wdt.h is not acceptable because the controller is sam3x.

How can I include the wdt.h for sam3x? I'm using the arduino 1.5.8a framework.

The sketch should look like this:

#include <wdt.h>  //unable to locate it unless I include the full path, but the dependencies in this case are not included

void setup() {
....
}

void loop() {
...
}

MorganS

I thought it's fairly obvious from Bob's pull request. Just modify your own installation of Arduino.h, main.cpp etc. as per the files that he modified. Since it's not part of the core yet, this must be done manually on each computer you expect to use to compile sketches. (Teensyduino does exactly this in a slightly more automated way.)

It can't be done as a regular library that's #included in a sketch.
"The problem is in the code you didn't post."

johnf95037

I may be overlooking something, but I can't find variant.cpp or variant.h for IDE 1.6.3.  I can find it in my IDE 1.5.8 install.

For the 1.5.8 install, they are in: \Documents\Arduino\hardware\arduino\sam\variants\arduino_due_x

For the 1.6.3 install, I don't have don't have a path to sam\variants\arduino_due_x

I just have: C:\Program Files (x86)\Arduino\hardware\arduino\

And the only selection in the hardware\arduino directory is avr

Thanks,
-j

bobcousins

Unfortunately, after the sudden and badly thought out release of the board and library manager, I've no idea where these files are now. The location is likely to change until Arduino figure out the right place to put them, which is probably where they were in the first place.

In 1.6.3, they are probably under "My Documents" somewhere. Obviously you need to install support for the Due in the Board Manager first.

Please ask questions in the forum so everyone can benefit. PM me for paid work.

koppels

I had the same problem but i have it fixed

http://forum.arduino.cc/index.php?topic=314647.0

johnf95037

Hey Bob,

I did find out I needed to use the board manager to install Due support.  I'm searching my drive for the files right now.

Kopples, I take a look at your suggestions.

Thanks,
-j

johnf95037

Ok found the files.  Sheesh.  That's an obscure location.

C:\Users\DUC\AppData\Roaming\Arduino15\packages\arduino\hardware\sam\1.6.3\variants\arduino_due_x

Now to get the WDT up and working.

Cheers,
-j

johnf95037

Hey Bob,

I made the file changes and additions as per your pull.  As far as using it in setup() and loop(), what needs to be done?

Thanks,
-j

bobcousins

Here is one of the test cases I used which should illustrate it's use:
Code: [Select]

// Due Watchdog test case
// - enable the watchdog and demonstrate that wdt_reset() prevents timeout

void watchdogSetup(void)
{
  watchdogEnable(1000);
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println ("start");
}

void loop() {
  // put your main code here, to run repeatedly:

  // this should not cause a watchdog timeout
  while (1){
    delay (100);
    Serial.println(millis());
    watchdogReset();
  }
 
}
Please ask questions in the forum so everyone can benefit. PM me for paid work.

johnf95037

Thank you sir.  I'll give it a try.
-j

johnf95037

It works great.  I tried a couple scenarios to force a system reset and to operate properly with the watchdog running in the background.

Thanks,
-j

germancorrea

koppels

I followed your instructions in http://forum.arduino.cc/index.php?topic=314647.0 and your code to test the watchdog function works fine.

Can you supply code how to use to use regulary

Thanks

RTurner_nexus

I was trying to use the great data in this thread but found at my 1.6.7 level the WDT_disable() call is no longer in the arduino_due_x\variant.cpp file.
What seems to have happened is the introduction of watchdog.cpp and watchdog.h in arduino\hardware\sam\1.6.7\cores\arduino directory.

Within the watchdog.cpp there is a watchdogSetup() defined so that it has a weak reference to a WDT_disable(WDT); call.  This stops the watchdog timer interupting sketches that dont use it.
So if you want to use the watchdog timer at this level, enable it by putting the following in your sketch.

void watchdogSetup(void) { }

This function can be empty as shown and creates a strong reference thus overiding the WDT_disable(WDT).

Then you should be able to use the "watchdog.h" or "wdt.h" calls.

Go Up