PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
WatchDog_Demo.cpp

Feed the dog a few times to show that the Propeller doesn't reset when fed correctly. Then stop feeding the dog and demonstrate how the Propeller will do a hard reset when the timer runs out

cmake_minimum_required(VERSION 3.12)
find_package(PropWare REQUIRED)
project(WatchDog_Demo)
create_simple_executable(${PROJECT_NAME} WatchDog_Demo.cpp)
// Includes
static uint32_t watchDogStack[96];
int main () {
WatchDog watchDog(watchDogStack, 1 * SECOND);
Runnable::invoke(watchDog);
for (int i = 0; i < 5; ++i) {
pwOut.printf("Resetting timer: %d\n", i);
watchDog.reset();
waitcnt(250*MILLISECOND + CNT);
}
int j = 0;
while (true) {
pwOut.printf("Resetting soon... %d\n", j++);
waitcnt(400*MILLISECOND + CNT);
}
}
printer.h
PropWare::Printer::printf
void printf(const char fmt[], const T first, const Targs... remaining) const
Similar in functionality to the C-standard function printf.
Definition: printer.h:497
main
int main(void)
Definition: GraphicsTest.c:20
PropWare::Runnable
Helper class for creating easy parallel applications.
Definition: runnable.h:75
PropWare::WatchDog
Simple WatchDog object for resetting the chip if it stops responding.
Definition: watchdog.h:37
watchdog.h
pwOut
PropWare::Printer pwOut
Most common use of printing in PropWare applications (not thread safe; see PropWare::pwSyncOut for mu...
waitcnt
#define waitcnt(a)
Wait until system counter reaches a value.
Definition: propeller.h:176
CNT
#define CNT
The system clock count.
Definition: propeller1.h:151
PropWare
Generic definitions and functions for the Parallax Propeller.
Definition: runnable.h:33