Reboot Teensy programmatically ...

Status
Not open for further replies.

drnicolas

Active member
Is there a safe way to do an intended reboot for my Teensy?
I read a little and it sounds that all methods seem to be complicated, needing hardware changes and/or are prone to damage the Teensy even substantially.

And - why is such a method NOT implemented so far?
 
OKay, I am currently using a Teensy 3.6.
I know this posting and was searching for a more straightforward method.
 
Code:
#define CPU_RESTART_ADDR (uint32_t *)0xE000ED0C
#define CPU_RESTART_VAL 0x5FA0004
#define CPU_RESTART (*CPU_RESTART_ADDR = CPU_RESTART_VAL);

This is pretty easy and should work given those three lines:

Code:
      if ( 'r' == foo ) CPU_RESTART; // restart CPU
 
This is what I do on the Teensy 4.0
Code:
void doReboot() {
  saveStatus();
  // send reboot command -----
  SCB_AIRCR = 0x05FA0004;
}
saveStatus() is my routine to save the machine state in a FRAM.
This works for me.
 
This is what I do on the Teensy 4.0
Code:
void doReboot() {
  saveStatus();
  // send reboot command -----
  SCB_AIRCR = 0x05FA0004;
}
saveStatus() is my routine to save the machine state in a FRAM.
This works for me.

That is a cleaner example - where post #4 hard codes the value to a new #define :: #define SCB_AIRCR (*(volatile uint32_t *)0xE000ED0C) // Application Interrupt and Reset Control

... a simple search and found that one not using the #define.
 
Status
Not open for further replies.
Back
Top