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

		<item>
			<title>bart_dood on "Timers/Interrupts"</title>
			<link>http://forums.leaflabs.com/topic.php?id=609#post-3350</link>
			<pubDate>Wed, 12 Jan 2011 17:49:49 +0000</pubDate>
			<dc:creator>bart_dood</dc:creator>
			<guid isPermaLink="false">3350@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi Folks,&#60;/p&#62;
&#60;p&#62;I am pretty new here, I'm working on a motor driver application on the maple and have a question about interrupts and timers.&#60;br /&#62;
My app requires 3 external pin interrupts (however these always call the same function) when a change is detected high/low or low/high.&#60;br /&#62;
It also has 2 timed interrupts, one runs at 10khz (so 100 microseconds) and the other runs at 20hz (50,000 microseconds).&#60;br /&#62;
My code is as follows for the setup:&#60;/p&#62;
&#60;p&#62;// external interrupt setups for hall sensor detection&#60;/p&#62;
&#60;p&#62;    attachInterrupt(10, calcposition, CHANGE);                              // on change of state of pin 10, run calcposition function&#60;br /&#62;
    attachInterrupt(11, calcposition, CHANGE);                              // on change of state of pin 11, run calcposition function&#60;br /&#62;
    attachInterrupt(12, calcposition, CHANGE);                              // on change of state of pin 12, run calcposition function  &#60;/p&#62;
&#60;p&#62;  // internal interrupt setups for timing syncs etc, use Timer 4 which is associated with pins 5, 9, 14, 24. Should avoid conflicts. Is used for 10khz interrupt&#60;/p&#62;
&#60;p&#62;    Timer4.setChannel1Mode(TIMER_OUTPUTCOMPARE);&#60;br /&#62;
    Timer4.setPeriod(100);                                                  // timer period in microseconds, 100 is equal to 10khz&#60;br /&#62;
    Timer4.setCompare1(100);                                                // overflow might be small&#60;br /&#62;
    Timer4.attachCompare1Interrupt(torqueloop);                             // when the interrupt triggers run the function torqueloop&#60;/p&#62;
&#60;p&#62;  // internal interrupt setups for timing syncs etc, use Timer ????&#60;/p&#62;
&#60;p&#62;    Timer3.setChannel1Mode(TIMER_OUTPUTCOMPARE);&#60;br /&#62;
    Timer3.setPeriod(50000);                                                // timer period in microseconds, 50000 is equal to 50 milliseconds or 20hz&#60;br /&#62;
    Timer3.setCompare1(50000);                                              // overflow might be small&#60;br /&#62;
    Timer3.attachCompare1Interrupt(checkparms);                             // when the interrupt triggers run the function checkparms&#60;/p&#62;
&#60;p&#62;I have timer 4 on the 10khz interrupt as I am using pins 6, 7 and 8 as PWM output pins. I have timer 3 on the other timed interrupt.&#60;/p&#62;
&#60;p&#62;Should I set the overflow figure (I presume it is in microseconds??) to the same value as the interrupt timer value? as shown above.&#60;/p&#62;
&#60;p&#62;Does this look right? any insight is appreciated, I am new to using interrupts but my code absolutely has to have them.&#60;/p&#62;
&#60;p&#62;Thanks!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
