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

		<item>
			<title>poslathian on "Timer slew during startup?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=812#post-4917</link>
			<pubDate>Tue, 31 May 2011 17:38:20 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">4917@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Also note that auto-reset programming will be disabled when using SerialUSB.end(), requiring the button-mashing perpetual bootloader mode. SerialUSB can be re-enabled, however, with SerialUSB.begin()
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Timer slew during startup?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=812#post-4916</link>
			<pubDate>Tue, 31 May 2011 16:07:50 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">4916@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Jason,&#60;/p&#62;
&#60;p&#62;Thanks for the updates.  Does disabling USB and SysTick (via SerialUSB.end() and systick_disable() respectively) resolve the issue?&#60;/p&#62;
&#60;p&#62;Also, be aware that micros() and millis() won't work without SysTick.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>vonnieda on "Timer slew during startup?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=812#post-4878</link>
			<pubDate>Mon, 30 May 2011 01:02:00 +0000</pubDate>
			<dc:creator>vonnieda</dc:creator>
			<guid isPermaLink="false">4878@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I believe I have tracked this down to either the systick or the USBSerial. I saw another post talking about both of those issuing a high priority interrupt and that seems to be the problem.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>vonnieda on "Timer slew during startup?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=812#post-4874</link>
			<pubDate>Sun, 29 May 2011 14:54:34 +0000</pubDate>
			<dc:creator>vonnieda</dc:creator>
			<guid isPermaLink="false">4874@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Forgot to mention, I am using Maple IDE 0.0.10beta on a Maple rev 5.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>vonnieda on "Timer slew during startup?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=812#post-4873</link>
			<pubDate>Sun, 29 May 2011 14:49:27 +0000</pubDate>
			<dc:creator>vonnieda</dc:creator>
			<guid isPermaLink="false">4873@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi all, I am working on some timer stuff to eventually implement a multi-axis stepper driver. I'm noticing that during the first few seconds of operation I get some weird timer artifacts. &#60;/p&#62;
&#60;p&#62;Here is a screenshot showing the behavior: &#60;a href=&#34;http://dl.dropbox.com/u/19742583/Screen%20shot%202011-05-29%20at%2012.41.46%20PM.png&#34; rel=&#34;nofollow&#34;&#62;http://dl.dropbox.com/u/19742583/Screen%20shot%202011-05-29%20at%2012.41.46%20PM.png&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;And here is the sketch that is running:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;HardwareTimer timer1(1);

// GPIOA_BASE-&#38;gt;ODR &#124;= BIT(3)

void setup() {
  pinMode(0, OUTPUT);
  digitalWrite(0, LOW);

  timer1.pause();
  timer1.setPrescaleFactor(72);
  timer1.setChannel1Mode(TIMER_OUTPUT_COMPARE);
  timer1.setCompare(TIMER_CH1, 1);
  timer1.setOverflow(0xffff);
  timer1.attachCompare1Interrupt(handler1);
  timer1.refresh();
  // adding a delay(2000) here causes the weirdness to never happen
  timer1.resume();
}

void handler1() {
  if (digitalRead(0) == LOW) {
    digitalWrite(0, HIGH);
    timer1.setCompare(TIMER_CH1, timer1.getCompare(TIMER_CH1) + 10);
  }
  else {
    digitalWrite(0, LOW);
    timer1.setCompare(TIMER_CH1, timer1.getCompare(TIMER_CH1) + 60);
  }
}

void loop() {
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;What I am seeing is that about a .25 seconds after startup I seem to miss the interrupt that turns off the output, so the timer does a full cycle (65ms) and then it happens again about 1 second in. After this it is fine and remains stable. If I add a 2000 ms delay before I resume the timer (starting it) this never happens. &#60;/p&#62;
&#60;p&#62;My guess is that the Maple library is setting something up during the first second of operation, but I have not confirmed that. &#60;/p&#62;
&#60;p&#62;Does anyone have any ideas as to what might be going on?&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Jason von Nieda
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
