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

		<item>
			<title>poslathian on "Timers - some quick code to test them"</title>
			<link>http://forums.leaflabs.com/topic.php?id=50#post-613</link>
			<pubDate>Fri, 23 Jul 2010 23:58:33 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">613@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This thread is a bit stale I suppose, but i should mention timer support has been added to wirish in our 0.0.6 release. Check it out! &#60;a href=&#34;http://leaflabs.com/docs/maple/timers/&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/maple/timers/&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "Timers - some quick code to test them"</title>
			<link>http://forums.leaflabs.com/topic.php?id=50#post-232</link>
			<pubDate>Fri, 11 Jun 2010 11:49:38 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">232@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;awesome! timers.h is the low level access lib from libmaple, eventually wed like to add a timers api to wirish (the cpp, &#34;arduino lib&#34; part of our library). I'm not sure exactly what the api will look like, but well try and include hooks for interrupts. Keep us posted on your progress!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>efox on "Timers - some quick code to test them"</title>
			<link>http://forums.leaflabs.com/topic.php?id=50#post-230</link>
			<pubDate>Fri, 11 Jun 2010 08:38:28 +0000</pubDate>
			<dc:creator>efox</dc:creator>
			<guid isPermaLink="false">230@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;sorry the code above will not work (for you). I appended the timers.c and timers.h file for my functions, and forgot to post those functions along with the test code. ill post them when i get home, but all they are are just slightly modified existing functions.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>efox on "Timers - some quick code to test them"</title>
			<link>http://forums.leaflabs.com/topic.php?id=50#post-229</link>
			<pubDate>Thu, 10 Jun 2010 23:35:26 +0000</pubDate>
			<dc:creator>efox</dc:creator>
			<guid isPermaLink="false">229@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;After getting blinky to work (like i had to really do anything :p ) i thought id check out the timers. It seems to me that there are approx 4 general purpose timers. SOOOOOOOOOOOOOO many options.&#60;/p&#62;
&#60;p&#62;I wrote up something just to start,stop,and read a timer. Nothing fancy, I just wanted to see it work ! I'll attempt to keep appending this with new unlocked features (lol..yes it does sound like a video game)...there are so many things that can be done with timers...hopefully i can create my own timer library that would do basic to intermediate tasks...i'll post more as I progress&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#include &#38;quot;stdlib.h&#38;quot;

HardwareUsb Serial;
int ledPin =  13;    // LED connected to digital pin 13
char rxBuffer;
uint8 numTimer=0;
uint8 timerArray[4] = {1,2,3,4};
uint16 counterVal;
uint8 loopControl=0;
// The setup() method runs once, when the sketch starts

void setup()   {
  // initialize the digital pin as an output:
  pinMode(ledPin, OUTPUT);
  timer_general_init(timerArray[1],1); //timer 2, 1 prescale
  timer_general_init(timerArray[2],1); //timer 3, 1 prescale
  timer_general_init(timerArray[3],1); //timer 4, 1 prescale
  Serial.print(&#38;quot;Enter Timer No.:&#38;quot;);
}

void loop()
{
    Serial.print(&#38;quot;Timer No.:&#38;quot;);
    loopControl=0;
    while(!loopControl )
    {
       if(Serial.available() &#38;gt; 0 )
       {
         loopControl = 1;
         rxBuffer = Serial.read();
         if(rxBuffer == &#38;#39;1&#38;#39;)
           numTimer = 1;
         else if(rxBuffer == &#38;#39;2&#38;#39;)
           numTimer = 2;
         else if (rxBuffer == &#38;#39;3&#38;#39;)
           numTimer = 3;
         else if (rxBuffer == &#38;#39;4&#38;#39;)
           numTimer = 4;
         else
           numTimer = 2; //lets this as the default timer
       }
   }
   Serial.print(&#38;quot;Timer &#38;quot;);
   Serial.println(numTimer);
   Serial.print(&#38;quot;Command:&#38;quot;);
   while(loopControl)
   {
     if(Serial.available() &#38;gt; 0 )
     {

       rxBuffer = Serial.read();
       if(rxBuffer == &#38;#39;r&#38;#39;) //read
       {
           counterVal=timer_read_count(numTimer); //read current timer val
           Serial.print(&#38;quot;Counter:&#38;quot;);
           Serial.println(counterVal);
       }
       else if(rxBuffer == &#38;#39;d&#38;#39;) //disable
       {
          timer_en_dis(numTimer,0);
       }
       else if (rxBuffer == &#38;#39;e&#38;#39;) //enable
       {
         timer_en_dis(numTimer,1);
       }
       else if (rxBuffer == &#38;#39;b&#38;#39;) //back out
       {
          loopControl =0;
       }
       else
       {
          Serial.println();
          Serial.println(&#38;quot;Invalid&#38;quot;);
          Serial.println(&#38;quot;Command:&#38;quot;);
       }
     }

    //timers_set_reload(numTimer,inByte);
    //countVal=timer_read_count(numTimer);
    //Serial.println(counter);

   }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;lol..i'll make it look prettier later..but feel free to change it up to test the timers out so you know how it works. This was something quick for me and suited my curiosity but if you want to add more...please do and POST HERE !! sharing ftw !
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
