Hardware reset / restart on Teensy RC

Status
Not open for further replies.

emseedee

Member
Hi, all,

I'm building an irrigation controller for the greenhouse on my allotment as my first venture into teensy-land. I built the prototype using an Arduino Uno, but for reasons of cost, power and size, I'm planning to use an LC for the final version. The one function that's present on the Uno but not on the LC is a reset line, and I was planning to use this as part of my design.


It seems to me that there is an alternative approach - to momentarily interrupt the power, which hopefully will cause the LC to restart. Are there any major problems with doing this, or is there a better way of performing a full reset?


Thanks in advance

Mike
 
You could enable the LC watchdog timer, and use it to restart the CPU via a timeout or software trigger
 
I'm not sure that's quite what I want - perhaps I should have been clearer. I want to be able to press a button and restart the system.

Basically, the unit runs a few checks, then performs a watering cycle. It then waits for an hour before repeating itself. During setup (or at any time to check things are working OK), I want to be able to perform the watering cycle on demand. The way I had intended to do this was simply to reset the unit, which is what I do on the Uno. If I could do it on the LC I wouldn't have to change my code.
 
Unfortunately there is no physical reset button on LC. You can either do it via software (you can trigger a reset via a button push using a GPIO, thereby calling a system reset OR a watchdog reset), or via hardware with extra components to temporarily cut and restore main power........

Why would you reset it if you can just use a GPIO to trigger the code..?
 
That's what I suspected. I just wanted to double check that there weren't any hidden "gotcha's" with the power interrupt method.

The other approach would be to abort the 1 hour delay using a push button switch on a dig I/O pin, but this would mean moving from the current approach of using delay() to one using millis().

On balance, if it's safe, I'll probably just interrupt the power line.

Mike
 
Here is the code to reset the LC via software, just use any GPIO as an input source:

Code:
SCB_AIRCR = 0x05FA0004;

something like:

Code:
(setup)
pinMode(5,INPUT_PULLUP);
while ( !digitalReadFast(5) );

(loop)
if ( !digitalReadFast(5) ) SCB_AIRCR = 0x05FA0004;

the while loop in setup will prevent consecutive resets until you let go of the button :)
 
The other approach would be to abort the 1 hour delay using a push button switch on a dig I/O pin, but this would mean moving from the current approach of using delay() to one using millis().
That's certainly the more elegant way of doing it (IMO). Your other method strikes me as rather primitive. Might as well wean yourself off delay() reliance now.
 
And the answer is...

In the end I used an interrupt to catch the switch press; the ISR calls the reset code snippet.

If anyone's interested, the code is:

Code:
setup(){
.
.
  pinMode(switch_pin, INPUT_PULLUP); 
  while ( !digitalReadFast(switch_pin) ); // pause until reset switch released
  attachInterrupt(digitalPinToInterrupt(switch_pin),rst_ISR, FALLING);
.
.
.
}
void rst_ISR() {
 /* 
  *  Run this code to perform a software reset when the reset button is pressed
  */
  SCB_AIRCR = 0x05FA0004;
}

Thanks to all who help me get there !
 
Status
Not open for further replies.
Back
Top