<?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: Interrupts and Delays</title>
		<link>http://forums.leaflabs.com/topic.php?id=305</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:18:39 +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=305" rel="self" type="application/rss+xml" />

		<item>
			<title>Silntknight on "Interrupts and Delays"</title>
			<link>http://forums.leaflabs.com/topic.php?id=305#post-2255</link>
			<pubDate>Sun, 07 Nov 2010 19:57:34 +0000</pubDate>
			<dc:creator>Silntknight</dc:creator>
			<guid isPermaLink="false">2255@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Gbulmer, you might remember how we discussed a kill switch for my engine project. This is for the kill switch. All I need to do is stop the Maple from writing outputs. I like the idea of &#60;code&#62;pwmWrite(0)&#60;/code&#62; so I might just use that. I had originally hoped that &#60;code&#62;delay()&#60;/code&#62; would take care of that, but I am not sure. Interrupts do not need to be stopped. I originally thought that they did, but I realized that stopping interrupts wouldn't actually kill the engine. The only way to actually stop it is to stop the fuel injector from injecting, so writing 0 for the PWM solves that problem. I'd also write 0 for the other 3 PWMs just because I don't need my valves opening every six seconds and the spark randomly firing. Don't worry, I'm not trying to do something terribly complicated here. Thanks!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "Interrupts and Delays"</title>
			<link>http://forums.leaflabs.com/topic.php?id=305#post-2246</link>
			<pubDate>Sun, 07 Nov 2010 17:51:51 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">2246@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I agree here, if you need accurate timing, a blocking call to delay() wrapped in interrupt disable/enable is probably not the write approach. Its also worth noting that USB interrupts, while they will fool with your timing, wont cause you to be more than a couple milliseconds off (at most, usually microseconds) so perhaps that doesnt actually hurt you in your specific case.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Interrupts and Delays"</title>
			<link>http://forums.leaflabs.com/topic.php?id=305#post-2239</link>
			<pubDate>Sun, 07 Nov 2010 14:51:29 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">2239@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;It is likely worth the effort to get very clear about what needs to happen and why.&#60;/p&#62;
&#60;p&#62;I think switching off interrupts for more than a couple of microseconds is rarely a good approach. Put another way; when someone asks me &#34;how do I switch off interrupts for a second or two?&#34;, my answer is usually &#34;rewrite the program so it isn't necessary&#34;&#60;/p&#62;
&#60;p&#62;The STM32F timers can be used in a huge number of different ways, and PWM is only one of them. If the question comes about because PWM doesn't do what is needed, then it is &#60;em&#62;EXTREMLY&#60;/em&#62; likely that PWM is not the appropriate solution. A single shot event timer, or a triggered countdown may be a more appropriate approach.&#60;/p&#62;
&#60;p&#62;If all that is needed is to stop PWM signals, &#60;code&#62;pwmWrite(0);&#60;/code&#62; will do it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "Interrupts and Delays"</title>
			<link>http://forums.leaflabs.com/topic.php?id=305#post-2226</link>
			<pubDate>Sun, 07 Nov 2010 13:51:58 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">2226@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;you can disable interrupts temporarily with the way youve shown. There are also low level instructions for temporarily disabling interrupts. Be aware that the auto-reset feature (that lets you hit upload without hitting reset) relies on the SerialUSB to be functional, which requires USB interrupts to fire. So if you disable interrupts, make sure to turn them back on!   &#60;/p&#62;
&#60;p&#62;Those low level instructions are:&#60;br /&#62;
#define DSB_ALL_C asm volatile(&#34;cpsid i&#34;);&#60;br /&#62;
#define ENB_ALL_C asm volatile(&#34;cpsie i&#34;);
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Interrupts and Delays"</title>
			<link>http://forums.leaflabs.com/topic.php?id=305#post-2221</link>
			<pubDate>Sun, 07 Nov 2010 11:33:59 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">2221@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;If an interrupt is enabled and is triggered, it will run.&#60;/p&#62;
&#60;p&#62;What it is that you are trying to make happen, and what is the state of the system?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Silntknight on "Interrupts and Delays"</title>
			<link>http://forums.leaflabs.com/topic.php?id=305#post-2218</link>
			<pubDate>Sat, 06 Nov 2010 21:40:26 +0000</pubDate>
			<dc:creator>Silntknight</dc:creator>
			<guid isPermaLink="false">2218@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;If I have a delay of 1 second in my code and external interrupts, which takes precedence? I am pretty sure that interrupts do, but I am not sure. I know that at some point during the delay, the condition for the interrupt will be satisfied, but I DO NOT want the interrupt process to occur. If the delay takes precedence, then I am fine. If the interrupt takes precedence, then I was thinking something like:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;detachInterrupt(8);
delay(1000);
//...At some later point in time...//
attachInterrupt(8, pulse, RISING);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I'd hate to do this because it would make my code somewhat more complex, because I would be reattaching the interrupt every loop.&#60;/p&#62;
&#60;p&#62;A solution to my proposed problem is to make a new condition (using the full code):&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if (digitalRead(13) = LOW) {
  //loop//
} else {
  delay(1);
  if (digitalRead(13) = HIGH) {
    delay(1000);
    if (digitalRead(13) = LOW) {
      attachInterrupt(8, pulse, RISING);
    }
  }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Finally, would a PWM keep running through the loop? The whole point of the loop is to stop the PWMs in the loop from running, but if they keep running during the delay, then it would defeat the point of making the delay like this. If PWMs keep running, I was thinking of &#60;code&#62;TimerX.setCount(100);&#60;/code&#62; inside the if statement (replacing the &#60;code&#62;delay(1000);&#60;/code&#62; and what follows it). That would freeze all PWMs.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
