Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware reset ?? huh #217

Closed
Yardie- opened this issue Aug 2, 2020 · 3 comments
Closed

Hardware reset ?? huh #217

Yardie- opened this issue Aug 2, 2020 · 3 comments

Comments

@Yardie-
Copy link

Yardie- commented Aug 2, 2020

I have been trying to get my head around how to actually use the reset/upi pin as a hardware reset.
I have used your software trick to great effect but I was wondering how to just enable the pin directly.

attaching an interrupt to trigger it
or reading the pin during the loop
then calling the reboot function would work

But the datasheet seems to say by setting the RSTPINCFG to 0x2 would enable it.
I only use the Arduino IDE to set the fuses and it doesnt seem to have it as an option.
I can understand why too many choices = too many problems. 🔢

Is this just something that we need to do directly??

@SpenceKonde
Copy link
Owner

SpenceKonde commented Aug 2, 2020 via email

@Yardie-
Copy link
Author

Yardie- commented Aug 2, 2020

Hi Spence
Good call I thought that was probably the case.
If I want to take the risk I will do the research and burn the appropriate bits and watch the bricks fly.
Your software solution is clean and simple and setting an interrupt to trigger it isn't that hard.
Thanks heaps these are very cool little chips.

@Yardie- Yardie- closed this as completed Aug 2, 2020
@Yardie-
Copy link
Author

Yardie- commented Aug 5, 2020

Just for anyone following who wants some very simple code that just works.
It uses another pin. as reset pin.
Yeah it's easy enough to write yourself but cut and paste works for me :)

/*
both work just uncomment the vesion you want
*/
#define LED_PIN (int) 13
#define RESET_ME_PIN (int) 10

void reset_me()
{
   _PROTECTED_WRITE(RSTCTRL.SWRR,1);
}

void setup()
{
   pinMode(LED_PIN, OUTPUT);
   digitalWrite(LED_PIN, LOW); // at start turn off LED to show reboot
   pinMode(RESET_ME_PIN, INPUT_PULLUP);
   delay(1000);
   digitalWrite(LED_PIN, HIGH); // then turn LED on after one second
   //~ attachInterrupt (digitalPinToInterrupt(RESET_ME_PIN), reset_me, FALLING); // with interupts
}


void loop()
{
   if(digitalRead(RESET_ME_PIN) == LOW) reset_me(); // in the loop
}


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants