-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Watchdog Object #52
Comments
That would be a very small object unless I'm misinterpreting your message.
On Thu, Nov 19, 2015 at 1:51 PM, David Zemon [email protected]
|
It might well end up being a very small object - I'm okay with that. Care to post code for your idea? And glad you like it! I haven't any questions on it in a very long time so I was wondering if anyone was still using it. |
Here's what I'm imagining:
namespace PropWare {
class WatchDog : public Runnable {
public:
WatchDog(const unsigned int timeout, /* params for Runnable */)
: Runnable(/* params for Runnable */),
m_timeout(timeout),
m_currentCog(cogid()) { }
void reset () {
this.m_timer = CNT;
}
void run () {
unsigned int timeSinceLastReset;
this->m_timer = CNT;
while (1) {
waitcnt(SLEEP_TIME + CNT);
timeSinceLastReset = CNT - this->m_timer;
if (timeSinceLastReset > this->timeout) {
for (uint8_t cog = 0; cog < 8; ++cog) {
if (this->m_currentCog != cog)
cogstop(cog);
cognew(main);
cogstop(this->m_currentCog);
}
}
}
}
private:
const unsigned int m_timeout;
const uint8_t m_currentCog;
volatile unsigned int m_timer;
}
} |
Yes! A way to optionally reset the entire chip would be nice - I usually do On Fri, Nov 20, 2015 at 9:55 AM, David Zemon [email protected]
|
What does |
Also, looks like I forgot a loop in my code above. Whoops! |
Thread started on how to reset the Propeller |
Sorry, David, brainfart! it's actual $80,not $7F of CLK register. It does PropManual v1.2, p28 under CLK register definition for bit 7: 0 On Fri, Nov 20, 2015 at 10:49 AM, David Zemon [email protected]
|
0 On Fri, Nov 20, 2015 at 10:49 AM, David Zemon [email protected]
|
Ha! How cool is that!? :D |
Simple nuclear option! :-) On Fri, Nov 20, 2015 at 11:33 AM, David Zemon [email protected]
|
Okay, so new code as recommended, using the namespace PropWare {
class WatchDog : public Runnable {
public:
WatchDog(const unsigned int timeout, /* params for Runnable */)
: Runnable(/* params for Runnable */),
m_timeout(timeout),
m_currentCog(cogid()) { }
void reset () {
this.m_timer = CNT;
}
void run () {
unsigned int timeSinceLastReset;
this->m_timer = CNT;
while (1) {
waitcnt(SLEEP_TIME + CNT);
timeSinceLastReset = CNT - this->m_timer;
if (timeSinceLastReset > this->timeout)
__builtin_propeller_clkset(0x80); // Hard reset
}
}
private:
const unsigned int m_timeout;
const uint8_t m_currentCog;
volatile unsigned int m_timer;
}
} |
That should do it for a full reset. Another variation would be to have the
On Fri, Nov 20, 2015 at 1:46 PM, David Zemon [email protected]
|
I like the idea of expanding this to have 7 individual watchdogs, or optionally one global.... and it shouldn't require much more space at all to do so. |
Yes, you have concisely stated what I wanted to concisely state. On Fri, Nov 20, 2015 at 2:08 PM, David Zemon [email protected]
|
Feel free to give it a try. The first couple tries were written at a coffee shop without a board, henceforth the re-committing multiple times. |
I've added another issue for expanding to 7 independent timers |
A common peripheral on other microcontrollers is the "watchdog" which will reset the CPU if the watchdog is not fed periodically. A watchdog object in PropWare would be a great addition.
The text was updated successfully, but these errors were encountered: