Looking for code to do a software restart with the Teensy LC

Status
Not open for further replies.

GregM

Active member
First, I have to say the the prjc.com site has a lot of documentation for their products. However, after reading the programming manual for Freescale MKL26Z64, I am confused. The manual says a software restart can be done. The problem is the manual refers to another document for the ARM processor. I did do a Google search for information on "Teensy LC restart" without any luck.

I am using this code for the same function with Teensy 3.1:
Code:
#define SCB_AIRCR (*(volatile uint32_t *)0xE000ED0C) // Application Interrupt and Reset Control location

void softRestart(int pinUsed) {
  int test1 = HIGH;
  int test2 = LOW;
  test1 = digitalRead(pinUsed);
  delay(100); //for debounce
  test2 = digitalRead(pinUsed);
  if ((test1 == test2) && (test1 == LOW)) {
    delay(1000); //allow human to release button
    Serial.end();  //clears the serial monitor  if used
    //turn off serial for restart, it will be properly turned after restart with IDE serial monitor
    //However, microcom and putty serial connection is killed after restart with or without serial.end()!
  SCB_AIRCR = 0x05FA0004;  //write value for restart
  }

I suspect the same code could be used, but, with a different register location and value. Thank you in advance for any help on this one.

Enjoy Life, Greg
Live Well, Laugh Often, Love Much
 
Thanks, mlu! I will try NVIC_SystemReset(void). It seems the easier approach.

Enjoy life, Greg
Live Well, Laugh Often, Love Much

Try the NVIC_SystemReset(void) and got a compilation error of "not in scope". This must be a library call, but, what library?
 
Last edited:
Somewhere in these forums, there are other/different solutions to doing a software reset on the Teensy 3.1. May work too for the LC, or with small changes.
It didn't use the NVIC-direct mechanism.
 
Thank Paul, for the confirmation that "SCB_AIRCR = 0x05FA0004;" should work. After checking the connections and re-doing them, it now works. It is not as fast as with the Teensy 3.1, I may have to change something in the code. But, it does work. Thank you to all for the help. Maybe now, I can do something useful.

Enjoy Life, Greg
Live Well, Laugh Often, Love Much
 
Follow Up, Found Post with Information

I was looking for some other information and found this post with Teensy Tips and Tricks:https://forum.pjrc.com/threads/25395-Teensy-Quick-Reference-Code-Examples-Tips-and-Tricks

It has provides a link to for a restart code. This is a compiler macro :
Code:
#define RESTART_ADDR       0xE000ED0C
#define READ_RESTART()     (*(volatile uint32_t *)RESTART_ADDR)
#define WRITE_RESTART(val) ((*(volatile uint32_t *)RESTART_ADDR) = (val))

To restart the program, one calls this in code:
Code:
WRITE_RESTART(0x5FA0004);

I have tried this and it does work with my projects. The referenced post with the tips and tricks has a lot of good information. I hope this is a help to someone.

Enjoy life, Greg
Live Well, Laugh Often, Love Much
 
I have the same question for teensy 4. I've tried various things and they all lock up the processor, but it's doesn't come back up.

My vote is for a reboot() to be written and supported for all teensy MCUs.
 
I have the same question for teensy 4. I've tried various things and they all lock up the processor, but it's doesn't come back up.

I'm also having the same experience on teensy 4, any advice on who to reboot/reset teensy4?
 
Status
Not open for further replies.
Back
Top