<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: reset function</title>
		<link>http://forums.leaflabs.com/topic.php?id=16585</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:14:17 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=16585" rel="self" type="application/rss+xml" />

		<item>
			<title>stephanschulz on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-33785</link>
			<pubDate>Thu, 26 Sep 2013 20:41:31 +0000</pubDate>
			<dc:creator>stephanschulz</dc:creator>
			<guid isPermaLink="false">33785@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;yes i do.&#60;br /&#62;
thank you very much for your help.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-33783</link>
			<pubDate>Thu, 26 Sep 2013 20:18:36 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">33783@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I have no time to look into it, but it seems &#60;em&#62;very&#60;/em&#62; weird that it isn't linked, yet &#60;code&#62;#include &#38;lt;usb_hardware.h&#38;gt;&#60;/code&#62; throws compile timer errors for multiple definitions.&#60;/p&#62;
&#60;p&#62;Anyway stephanschulz seems to have what he needs.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ala42 on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32848</link>
			<pubDate>Wed, 25 Sep 2013 20:02:37 +0000</pubDate>
			<dc:creator>ala42</dc:creator>
			<guid isPermaLink="false">32848@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I found nvic_sys_reset() in &#60;a href=&#34;https://github.com/leaflabs/libmaple/blob/master/libmaple/nvic.c&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple/blob/master/libmaple/nvic.c&#60;/a&#62; in the master branch when I read you did not have systemHardReset.&#60;br /&#62;
Anyway, at least in my sources systemHardReset is not declared as static, so the linker should find it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32846</link>
			<pubDate>Wed, 25 Sep 2013 19:53:22 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">32846@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;ala42 - &#60;em&#62;&#34;nvic_sys_reset() in the mean time, now defined in nvic.c.&#34;&#60;/em&#62;&#60;br /&#62;
Not for me. &#60;/p&#62;
&#60;p&#62;I have systemHardReset in usb_hardware.c, but it isn't linked in by the IDE, and I can't #include &#38;lt;usb_hardware.h&#38;gt; because I get multiple definitions.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ala42 on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32844</link>
			<pubDate>Wed, 25 Sep 2013 19:43:12 +0000</pubDate>
			<dc:creator>ala42</dc:creator>
			<guid isPermaLink="false">32844@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Looks like this function was named nvic_sys_reset() in the mean time, now defined in nvic.c.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32838</link>
			<pubDate>Wed, 25 Sep 2013 19:22:43 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">32838@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;ala42 - I don't believe systemHardReset() is linked via the IDE:&#60;/p&#62;
&#60;p&#62;&#60;em&#62;/var/folders/oE/oEzfk9h0HKOEXtVMI7BaCk+++TM/-Tmp-/build8154357291228699228.tmp/BlinkReset.o: In function `loop()':&#60;/p&#62;
&#60;p&#62;undefined reference to `systemHardReset()'collect2: ld returned 1 exit status&#60;/em&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ala42 on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32785</link>
			<pubDate>Wed, 25 Sep 2013 17:17:15 +0000</pubDate>
			<dc:creator>ala42</dc:creator>
			<guid isPermaLink="false">32785@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;systemHardReset() is the function called by the libmaple USB handler to reset the CPU before entering the boot code when the magic byte sequence is send before program upload. It is already in libmaple, so you just have to call it. You probably need to declare it as external or to include the .h where it is declared. There is no way you can get compiler errors for as long as you did not try to re-event the wheel and pasted the code which is already present in libmaple.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stephanschulz on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32721</link>
			<pubDate>Wed, 25 Sep 2013 14:31:58 +0000</pubDate>
			<dc:creator>stephanschulz</dc:creator>
			<guid isPermaLink="false">32721@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;very very nice. thank you. this made it work for both the blink test and the serial test.&#60;/p&#62;
&#60;p&#62;here are my two test sketches:&#60;/p&#62;
&#60;p&#62;serial test&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#define SCB_AIRCR ((volatile uint32*) (0xE000ED00 + 0x0C))
#define SCB_AIRCR_SYSRESETREQ (1 &#38;lt;&#38;lt; 2)
#define SCB_AIRCR_RESET ((0x05FA0000) &#124; SCB_AIRCR_SYSRESETREQ)

int cnt = 0;

void setup() {
   pinMode(BOARD_LED_PIN, OUTPUT);
   digitalWrite(BOARD_LED_PIN,HIGH);

    SerialUSB.println(&#38;quot;hi&#38;quot;);
    cnt = 0;
}

void loop(){
  SerialUSB.println(cnt);
  cnt++;

  delay(500);

  if(millis() &#38;gt; 10000){
      SerialUSB.println(&#38;quot;reset&#38;quot;);
    *(SCB_AIRCR) = SCB_AIRCR_RESET;
  }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;blink test&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#define SCB_AIRCR ((volatile uint32*) (0xE000ED00 + 0x0C))
#define SCB_AIRCR_SYSRESETREQ (1 &#38;lt;&#38;lt; 2)
#define SCB_AIRCR_RESET ((0x05FA0000) &#124; SCB_AIRCR_SYSRESETREQ)

boolean state;

void setup() {

  pinMode(BOARD_LED_PIN, OUTPUT);

  state = false;
  digitalWrite(BOARD_LED_PIN,state);

  delay(5000);
}

void loop() {
  if (millis() &#38;lt; 15000) {
    state = !state;
    digitalWrite(BOARD_LED_PIN,state);
    delay(500);
  }
  else{
    digitalWrite(BOARD_LED_PIN,HIGH);
   // *(SCB_AIRCR) &#124;= SCB_AIRCR_SYSRESETREQ;
   *(SCB_AIRCR) = SCB_AIRCR_RESET;
  }
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>mlundinse on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32668</link>
			<pubDate>Wed, 25 Sep 2013 13:32:03 +0000</pubDate>
			<dc:creator>mlundinse</dc:creator>
			<guid isPermaLink="false">32668@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Change the definition to&#60;/p&#62;
&#60;p&#62;#define SCB_AIRCR ((volatile uint32*) (0xE000ED00 + 0x0C))&#60;/p&#62;
&#60;p&#62;(otherwise the +0x0c will add 12 words to the base address, not 12 bytes )&#60;/p&#62;
&#60;p&#62;The actual reset must be done with:&#60;/p&#62;
&#60;p&#62;    *(SCB_AIRCR) = SCB_AIRCR_RESET;&#60;/p&#62;
&#60;p&#62;( &#124;=  will not work )
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stephanschulz on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32625</link>
			<pubDate>Wed, 25 Sep 2013 12:44:49 +0000</pubDate>
			<dc:creator>stephanschulz</dc:creator>
			<guid isPermaLink="false">32625@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;first, thanks for taking the time.&#60;/p&#62;
&#60;p&#62;here is a simple blinking code that should&#60;br /&#62;
boot&#60;br /&#62;
led off for 5 seconds&#60;br /&#62;
led blink until &#38;gt; 15 seconds&#60;br /&#62;
led on&#60;br /&#62;
reset&#60;/p&#62;
&#60;p&#62;boot ...&#60;/p&#62;
&#60;p&#62;but&#60;br /&#62;
it never seems to reset because the led stays on solid after 15 seconds&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#define SCB_AIRCR ((volatile uint32*) 0xE000ED00 + 0x0C)
#define SCB_AIRCR_SYSRESETREQ (1 &#38;lt;&#38;lt; 2)
#define SCB_AIRCR_RESET ((0x05FA0000) &#124; SCB_AIRCR_SYSRESETREQ)

boolean state;

void setup() {

  pinMode(BOARD_LED_PIN, OUTPUT);

  state = false;
  digitalWrite(BOARD_LED_PIN,state);

  delay(5000);
}

void loop() {
  if (millis() &#38;lt; 15000) {
    state = !state;
    digitalWrite(BOARD_LED_PIN,state);
    delay(500);
  }
  else{
    digitalWrite(BOARD_LED_PIN,HIGH);
    *(SCB_AIRCR) &#124;= SCB_AIRCR_SYSRESETREQ;
  }
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>gbulmer on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32457</link>
			<pubDate>Wed, 25 Sep 2013 09:25:25 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">32457@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;stephanschulz - I think it is resetting, it's the USBSerial which might not be working.&#60;/p&#62;
&#60;p&#62;I strongly recommend you debug using LEDs which are synchronous (and easy) and not SerialUSB (which is asynchronous and messy).&#60;/p&#62;
&#60;p&#62;Have a look at:&#60;br /&#62;
&#60;a href=&#34;http://leaflabs.com/docs/lang/api/serialusb.html#examples&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/lang/api/serialusb.html#examples&#60;/a&#62;&#60;br /&#62;
to see how to get that going if it is critical.&#60;/p&#62;
&#60;p&#62;I'd do a countdown in loop():&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;if (millis() &#38;lt; 10000) {
    toggleLED();
    delay(500);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;(Not compiled)&#60;br /&#62;
So that you can see something happening.&#60;/p&#62;
&#60;p&#62;AFAIK, SerailUSB relies on asynchronous interrupts to send characters up to the host PC.&#60;br /&#62;
So it is possible that the reset could happen *before* any characters printed by &#60;code&#62;SerialUSB.println(&#38;quot;reset&#38;quot;);&#60;/code&#62; are sent from the Maple up the USB interface to the host PC.&#60;/p&#62;
&#60;p&#62;You could prove that it is in setup by blinking the LED for a while with a distinct duration (and maybe increase the timeout from 10000 to make it easy to see what is happening)&#60;/p&#62;
&#60;p&#62;What I meant by download ala42's code is, go to ala42's web site or git, find and download all ala42's library source code, put it in the right place, then set up everything to use it. &#60;/p&#62;
&#60;p&#62;I think if you haven't done anything like this before, it might take you at least a few hours to get everything working in a way you understand. If this is very new, and you are not familiar with the command line, make, gcc and binutils, it might take days.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stephanschulz on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32412</link>
			<pubDate>Wed, 25 Sep 2013 08:09:56 +0000</pubDate>
			<dc:creator>stephanschulz</dc:creator>
			<guid isPermaLink="false">32412@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;all this blinking confuses me.&#60;/p&#62;
&#60;p&#62;i made this serial print example with your reset code, but it does not seem to reset; i.e. start with setup()&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#define SCB_AIRCR ((volatile uint32*) 0xE000ED00 + 0x0C)
#define SCB_AIRCR_SYSRESETREQ (1 &#38;lt;&#38;lt; 2)
#define SCB_AIRCR_RESET ((0x05FA0000) &#124; SCB_AIRCR_SYSRESETREQ)

int cnt;

void setup() {
   pinMode(BOARD_LED_PIN, OUTPUT);
   digitalWrite(BOARD_LED_PIN,HIGH);

    SerialUSB.println(&#38;quot;hi&#38;quot;);
    cnt = 0;
}

void loop(){
  SerialUSB.println(cnt);
  cnt++;

  delay(500);

  if(millis() &#38;gt; 10000){
      SerialUSB.println(&#38;quot;reset&#38;quot;);
      *(SCB_AIRCR) &#124;= SCB_AIRCR_SYSRESETREQ;
  }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;i am also not sure which steps i should take to follow this advice of yours&#60;br /&#62;
&#34;The errors would be fixed if you downloaded and installed ala42's source.&#34;&#60;br /&#62;
i copy pasted ala42's code in to my sketch, which did not work.&#60;br /&#62;
i pasted his code in to a separate .h file and included is like a library. so success.&#60;br /&#62;
i am sorry man. you really gotta take this newbie by the hands. :(
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32400</link>
			<pubDate>Wed, 25 Sep 2013 07:58:05 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">32400@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This seems to work fine on a Maple mini:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;/*
 BlinkReset

 by stephanschulz &#38;amp; gbulmer
*/

#define SCB_AIRCR ((volatile uint32*) 0xE000ED00 + 0x0C)
#define SCB_AIRCR_SYSRESETREQ (1 &#38;lt;&#38;lt; 2)
#define SCB_AIRCR_RESET ((0x05FA0000) &#124; SCB_AIRCR_SYSRESETREQ)

unsigned long resetTimer;

boolean initDone;

void setup() {
  // Set up the built-in LED pin as an output:
  pinMode(BOARD_LED_PIN, OUTPUT);

  initDone = false;
  resetTimer = millis();
}

void loop() {

  if(initDone == false){

    toggleLED();          // Turn the LED from off to on, or on to off
    delay(100);
    toggleLED();          // Turn the LED from off to on, or on to off
    delay(100);
    toggleLED();          // Turn the LED from off to on, or on to off
    delay(100);
    initDone = true;
  }
  // digitalWrite(BOARD_LED_PIN,HIGH);

  if(millis() - resetTimer &#38;gt; 10000){
    resetTimer = millis();
    digitalWrite(BOARD_LED_PIN,LOW);
    delay(500);
    digitalWrite(BOARD_LED_PIN,HIGH);
    delay(500);
    digitalWrite(BOARD_LED_PIN,LOW);
    delay(500);
    digitalWrite(BOARD_LED_PIN,HIGH);
    delay(500); 

    *(SCB_AIRCR) &#124;= SCB_AIRCR_SYSRESETREQ;   // Does a System Reset, and never returns

  }

  // Wait for 1 second (1000 milliseconds)
  toggleLED();          // Turn the LED from off to on, or on to off
  delay(1000);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;It slow blinks 5 times (2 second cycle), then does two rapid blinks when it times-out, then resets. The reset switches the LED off.&#60;/p&#62;
&#60;p&#62;I'd probably write&#60;br /&#62;
&#60;code&#62;if ( !initDone) {&#60;/code&#62;&#60;br /&#62;
instead of&#60;br /&#62;
&#60;code&#62;if(initDone == false){&#60;/code&#62;&#60;br /&#62;
but I didn't want to change it too much.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32384</link>
			<pubDate>Wed, 25 Sep 2013 07:36:05 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">32384@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;stephanschulz - The errors would be fixed if you downloaded and installed ala42's source.&#60;/p&#62;
&#60;p&#62;I believe this is everything needed:&#60;/p&#62;
&#60;p&#62;#define SCB_AIRCR ((volatile uint32*) 0xE000ED00 + 0x0C)&#60;br /&#62;
#define SCB_AIRCR_SYSRESETREQ (1 &#38;lt;&#38;lt; 2)&#60;br /&#62;
#define SCB_AIRCR_RESET         ((0x05FA0000) &#124;  SCB_AIRCR_SYSRESETREQ)&#60;/p&#62;
&#60;p&#62;*SCB_AIRCR &#124;= SCB_AIRCR_RESET;&#60;/p&#62;
&#60;p&#62;It should never reach the next line, because it has done a reset.&#60;br /&#62;
If it does reach the next line, then the reset failed.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stephanschulz on "reset function"</title>
			<link>http://forums.leaflabs.com/topic.php?id=16585#post-32097</link>
			<pubDate>Tue, 24 Sep 2013 20:27:40 +0000</pubDate>
			<dc:creator>stephanschulz</dc:creator>
			<guid isPermaLink="false">32097@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@ala42&#60;br /&#62;
just to be clear are you saying all i need to do is add posted code to my code and call systemHardReset() when want to reset?&#60;/p&#62;
&#60;p&#62;i tried but got these errors:&#60;/p&#62;
&#60;p&#62;&#38;lt;BUILD&#38;gt;/Blink.cpp: In function 'void systemHardReset()':&#60;br /&#62;
&#38;lt;BUILD&#38;gt;/Blink.cpp:27: error: 'rSCB' was not declared in this scope&#60;br /&#62;
&#38;lt;BUILD&#38;gt;/Blink.cpp:27: error: 'u32' was not declared in this scope&#60;br /&#62;
&#38;lt;BUILD&#38;gt;/Blink.cpp:27: error: expected ')' before ';' token&#60;br /&#62;
&#38;lt;BUILD&#38;gt;/Blink.cpp:27: error: expected primary-expression before '&#124;' token&#60;br /&#62;
&#38;lt;BUILD&#38;gt;/Blink.cpp:27: error: expected ';' before numeric constant
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
