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

		<item>
			<title>erock on "Timer Outputs"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1361#post-9885</link>
			<pubDate>Sun, 25 Mar 2012 16:19:13 +0000</pubDate>
			<dc:creator>erock</dc:creator>
			<guid isPermaLink="false">9885@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I am trying to do audio recording with the maple, and I am having trouble getting the timer to trigger an ADC conversion. Initially I tried using timer interrupts, but this interfered with the writing to the SD card. Now I am trying to use DMA with the ADC to get more time for the SD writes. I want the timer to trigger a conversion at 16 kHz, then the end of conversion should trigger the DMA to store the value in a buffer.  I have set up timer 1 CC1 event as the external event selector using adc.h. I have my prescaler, but I am lost on what else to do to create the CC1 event using timer.h. The above post describes exactly what I am trying to do, but I am having a hard time understanding it. I am not very strong in embedded systems, so any help would be greatly appreciated.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Rod on "Timer Outputs"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1361#post-8299</link>
			<pubDate>Tue, 21 Feb 2012 18:20:31 +0000</pubDate>
			<dc:creator>Rod</dc:creator>
			<guid isPermaLink="false">8299@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The timers work well as interrupt sources, but there is undocumented funkiness going on when you try and use them to trigger other internal peripherals.&#60;/p&#62;
&#60;p&#62;The worst part is the inconsistency of the ST documentation.&#60;/p&#62;
&#60;p&#62;For example, to trigger an A2D conversion via a timer event as an external source, you select an event (e.g. TIM1_CH1 event) as an external trigger source for the A2D, and then go looking in vain for 'TIM1_CH1 event' in the timer documentation. What you find is U event (update), CC1l (on the diagram but not described, although CCIIE and CCI1F are described), OC1REF, OC1and TI1 along with ITR1 (for cascading timers, see the slave mode control register documentation for routing ). You can, though, generate a capture/compare event via the CC1G bit in the TIMx_EGR register.&#60;/p&#62;
&#60;p&#62;The tricky bit is that the event (at least for the purpose of triggering an A2D) is only generated when the timer is in TIMER_PWM mode, not in TIMER_OUTPUT_COMPARE mode (even via SW changes to the EGR register).&#60;/p&#62;
&#60;p&#62;So basically different teams documented different peripherals and no one focused on  the inter peripheral communications for us poor users.&#60;/p&#62;
&#60;p&#62;Awesome when its working. Be sure and look for code examples, though, when stuff isn't working, rather than just assuming its something you mis-read in the documentation.&#60;/p&#62;
&#60;p&#62;gbulmer gives you a good line on the basics of timers. Here are a few more things that aren't immediately obvious:&#60;/p&#62;
&#60;p&#62;- the capture compare pins are both inputs and outputs; that's the same pin on both sides of the diagram. Also they can be clock source inputs (channel 1 and 2 anyway in external clock mode 1)&#60;/p&#62;
&#60;p&#62;- the ETF pin is both an external trigger and an external clock input (external clock mode 2).&#60;/p&#62;
&#60;p&#62;- the slave mode control register is poorly named. It is used to select other external clock sources as well as configuring slave mode (i.e. slave mode select field (SMS)).&#60;/p&#62;
&#60;p&#62;- note the path from TIMx_CH1 to TI1 to T1FP1 to IC1 to OC1REF to OC1 and back to TIMxCH1, on the diagram. That really helps to decode the documentation&#60;/p&#62;
&#60;p&#62;- for the new user, check out the alternate function section of GPIO, to move the signal pins around and enable them
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Timer Outputs"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1361#post-8266</link>
			<pubDate>Sun, 19 Feb 2012 08:43:21 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">8266@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;mvarey - each PWM output *is* the output of one channel of a timer. There are several types of timer, but in general, each timer has four channels (Timer 6 and 7 don't). Each channel has a pin which can act as input or output . The Maples setup for PWM sets up a timer channel pin to be an output.&#60;/p&#62;
&#60;p&#62;Maybe I have misunderstood your question, but the ETR pin is an input, typically it used to drive the timer's counter using an external signal. &#60;/p&#62;
&#60;p&#62;To get a particular frequency use the Hardware Timer functions &#60;a href=&#34;http://leaflabs.com/docs/lang/api/hardwaretimer.html#lang-hardwareTimer&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/lang/api/hardwaretimer.html#lang-hardwareTimer&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Frequency is set by dividing the main clock (72MHz) by a 'prescale' value, then by counting at that frequency to the 'upload' value.&#60;br /&#62;
In general use a 'pre scale' value as small as practical to give the maximum resolution on the upload value. Both values are 16bits, &#60;/p&#62;
&#60;p&#62;So if you need a higher frequency than 1,098Hz (actually 549Hz, see up/down counting), use a prescaler of 1. Then the 'upload' value sets the frequency, and it counts in multiples of 72MHz.&#60;/p&#62;
&#60;p&#62;The HardwareTimer function 'setPeriod' can be used to set this up too. The downside of that is the actual 'upload' value might be slightly inconvenient, i.e. odd when you want even, or vice versa.&#60;/p&#62;
&#60;p&#62;The default set up for the timer is called 'up/down counting'. This means the counter counts up to the 'upload' value, then downwards to zero, then back up to the 'upload'  value, etc. When the counter value of a channel matches the 'compare' value, that channel's pin is flipped. The compare value controls the duty cycle or mark/space ratio. Set it to half the 'upload' value for 50:50. The effect of up/down  counting is to give a symmetric wave form at &#60;strong&#62;&#60;em&#62;half&#60;/em&#62;&#60;/strong&#62; the frequency set by prescale &#38;amp; upload.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mvarey on "Timer Outputs"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1361#post-8262</link>
			<pubDate>Sat, 18 Feb 2012 17:17:41 +0000</pubDate>
			<dc:creator>mvarey</dc:creator>
			<guid isPermaLink="false">8262@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I have looked around for an example of setting up timers for the Maple (rev 5) so that the output appears on one of the pins.  It appears from the processor documentation that this is possible, but I have not found a way to accomplish this.  Has anyone got an example of setting up the timer3 ETR pin to enable it to output the timer output?&#60;/p&#62;
&#60;p&#62;I need to be able to generate a variable frequency in addition to the PWM output (which works great).
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
