Shop OBEX P1 Docs P2 Docs Learn Events
[C/C++] Reset Propeller via Software — Parallax Forums

[C/C++] Reset Propeller via Software

DavidZemonDavidZemon Posts: 2,973
edited 2015-11-20 15:41 in Propeller 1
I want to reset the Propeller via software only for the sake of a watchdog object. I know watchdogs are better implemented via R/C combination on the reset pin, but I think a software object would be nice way to learn about the concept without having to get out a breadboard. I'm sure others can think of reasons for software-only watchdogs.

Anyway, my question revolves around how to do a thorough reset of a C/C++ program on the Prop. Here's what I have so far:
int currentCog = cogid();
for (int cog = 0; cog < 8; ++cog) {
  if (currentCog != cog)
    cogstop(cog);
  cognew(main);
  cogstop(currentCog);
}

But I don't think this resets either the heap or the stack, so the program might very well run out of memory pretty quick!

Comments

  • Nonintuitively, clkset $80 works - Prop Manual v1.2, p28 under CLK register defs.
  • Absolutely beautiful. And I love that it's more thorough and takes less code space too :D
  • In Spin you can use REBOOT; was that feature not ported to C for the Propeller?
  • As of Nov 2012, no
    ersmith wrote: »
    Actually, rebooting the processor is accomplished by setting bit 7 in the clock mode using the CLKSET instruction (there is no REBOOT instruction, at least not in GAS). In PropGCC you can accomplish this by:
    #define reboot() __builtin_propeller_clkset(0x80)
    
    And then using ''reboot()'' whenever you want to reboot.

    Eric
Sign In or Register to comment.