<?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; User Favorites: crk</title>
		<link><a href='http://forums.leaflabs.com/profile.php?id=7029'>7029</a></link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:22:46 +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?profile=7029" rel="self" type="application/rss+xml" />

		<item>
			<title>mlundinse on "Wrong PWM frequency, 1.1kHz or 550Hz?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=15451&amp;page=2#post-30976</link>
			<pubDate>Fri, 20 Sep 2013 17:49:02 +0000</pubDate>
			<dc:creator>mlundinse</dc:creator>
			<guid isPermaLink="false">30976@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;timer.setPrescaleFactor(1);&#60;/p&#62;
&#60;p&#62;This should do it if timer is the hardware timer connected to the specific pin.&#60;/p&#62;
&#60;p&#62;The RM does not say PWM must be 550. I have tested it at 1.1 kHz with 16 bit resolution.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mlundinse on "Wrong PWM frequency, 1.1kHz or 550Hz?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=15451#post-30975</link>
			<pubDate>Fri, 20 Sep 2013 17:46:18 +0000</pubDate>
			<dc:creator>mlundinse</dc:creator>
			<guid isPermaLink="false">30975@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;just set the division factor to one (0 in the PSC registers) and its 1.1 kHz
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crk on "Wrong PWM frequency, 1.1kHz or 550Hz?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=15451#post-30974</link>
			<pubDate>Fri, 20 Sep 2013 17:28:19 +0000</pubDate>
			<dc:creator>crk</dc:creator>
			<guid isPermaLink="false">30974@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi, thank you everyone for the explanations.&#60;br /&#62;
So in conclusion the reference page is plenty wrong about the frequency,&#60;br /&#62;
all the outputs coming from all timers (TIM1 included) has not the 1.1kHz frequency.&#60;br /&#62;
Not only my oscilloscope, but also the RM0008 manual interpretation says the frequency has to be 550Hz! ;)&#60;br /&#62;
I'll contact the Leaflabs team for one their opinion.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mlundinse on "Wrong PWM frequency, 1.1kHz or 550Hz?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=15451#post-30954</link>
			<pubDate>Thu, 19 Sep 2013 15:17:59 +0000</pubDate>
			<dc:creator>mlundinse</dc:creator>
			<guid isPermaLink="false">30954@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The base timer clocks are running at 72Mhz. For a 36 MHz bus, bus clock divisor 2, the timer clock is 2x the bus clock as seen in the timer tree for the RCC.&#60;/p&#62;
&#60;p&#62;The setup value of the prescale registers is set 1, giving a prescale division factor of 2, making the timers run at 36 MHz.&#60;br /&#62;
With an auto reload of 65536 ( 0xFFFF ) this will give about 550Hz.&#60;/p&#62;
&#60;p&#62;The setting of PSC = 1 is done in wirish/boards.cpp : timer_default_config()
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Wrong PWM frequency, 1.1kHz or 550Hz?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=15451#post-30888</link>
			<pubDate>Thu, 19 Sep 2013 12:25:35 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">30888@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;crk - AFAICT you are correct, the code only sets upcounting. IMHO, you are also correct that the reference page is (partly) wrong.&#60;/p&#62;
&#60;p&#62;The Maple start-up code sets all timers pre-scaler is 0xFFFF, so if the source clock were 72MHz, then 72MHz / 0xFFFF = 1,099Hz&#60;/p&#62;
&#60;p&#62;However, Timer 1, is AFAICT on a different clock 'domain' (or bus), APB2, to the other timers which are on APB1 ('domain' or bus).&#60;/p&#62;
&#60;p&#62;APB2 can run at 72MHz but APB1 runs at a maximum of 36MHz (&#34;Figure 11. Clock tree&#34;, page 123/1096, RM0008, Doc ID 13902 Rev 14)&#60;/p&#62;
&#60;p&#62;The RM0008 manual says:  &#34;The maximum frequency of the AHB and the APB2 domains is 72 MHz. The maximum allowed frequency of the APB1 domain is 36 MHz.&#34; (page 124/1096)&#60;/p&#62;
&#60;p&#62;So, assuming I've read the manual correctly, the input clock to Timer 1 should be 72MHz, and the input clock to the other Timers should be 36MHz. Timers running at 36MHz should have a period of 36MHz/0xFFFF = 549Hz.&#60;br /&#62;
So that, combined with upcounting only, would explain that part of your measurement.&#60;/p&#62;
&#60;p&#62;IMHO you are correct, the page you linked is incorrect for the 'General Purpose' timers (TIM2 to TIM5).&#60;br /&#62;
However AFAICT Timer 1 (TIM1) should be running at 72MHz.&#60;/p&#62;
&#60;p&#62;So I don't understand why outputs from Timer 1 are running at the same frequency, and not twice that frequency.&#60;/p&#62;
&#60;p&#62;IIRC I've only measured the frequency of timer pulses when I am trying to get the timer to run at a specific frequency, usually by fiddling with the prescale value.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crk on "Wrong PWM frequency, 1.1kHz or 550Hz?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=15451#post-30825</link>
			<pubDate>Thu, 19 Sep 2013 04:07:28 +0000</pubDate>
			<dc:creator>crk</dc:creator>
			<guid isPermaLink="false">30825@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi gbulmer, and thank you for your interest!&#60;br /&#62;
I have measured this frequency with my oscilloscope in each pwm pin,&#60;br /&#62;
and comparing each pin with each other i noticed they are all rising edge alligned.&#60;br /&#62;
So i think all counters are up counters and all setted identically.&#60;br /&#62;
I'm talking about a Maple running at its bootloader defaults without modifying any timers registers.&#60;br /&#62;
Infact i don't have nothing particular to do, but i only wants to know if it is an issue or if the reference page linked before has been written wrong.&#60;br /&#62;
Have yuo ever measured the pwm frequency of your maple?&#60;br /&#62;
Thank you!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Wrong PWM frequency, 1.1kHz or 550Hz?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=15451#post-30747</link>
			<pubDate>Wed, 18 Sep 2013 21:12:41 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">30747@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;crk - Welcome to the forum. I hope we can help.&#60;/p&#62;
&#60;p&#62;How are you measuring the frequency?&#60;/p&#62;
&#60;p&#62;It's almost 3am here, so I'm not going to check, on a Maple I'm off to bed.&#60;br /&#62;
However, I think it might be slightly misleading documentation.&#60;/p&#62;
&#60;p&#62;There are a bunch of modes that Maple's STM32F103 (and Arduino ATmega) timers can operate in.&#60;/p&#62;
&#60;p&#62;One mode counts from 0 to 'max' in one cycle, then counts down from 'max' to 0 in one cycle, then it repeats counting up, then down. So each PWM pulse takes two cycles of the timer.&#60;/p&#62;
&#60;p&#62;IIRC, this is the mode which two of the Arduino's three timers use (the other is the clock for millis, and operates as a single cycle 0 to 255, 0 to 255 ... counter).&#60;/p&#62;
&#60;p&#62;I also think it is the mode that the Maple's STM32F103's timers are running in. This is called &#34;Center-aligned mode (up/down counting)&#34; in the RM0008 manual. It says &#34;Center-aligned mode is active when the CMS bits in TIMx_CR1 register are not equal to '00'.&#34; (page 359/1096)&#60;/p&#62;
&#60;p&#62;The register is TIMx_CR1, and the CMS bits are bits are bits 5 &#38;amp; 6 (page 388/1096)&#60;/p&#62;
&#60;p&#62;If you need it to run at 1.1KHz, you could do several things, using the timer API &#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;If you explain what you need to do, we may be able to help.&#60;/p&#62;
&#60;p&#62;(Full disclosure: I am not a member of LeafLabs staff.)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crk on "Wrong PWM frequency, 1.1kHz or 550Hz?"</title>
			<link>http://forums.leaflabs.com/topic.php?id=15451#post-30743</link>
			<pubDate>Wed, 18 Sep 2013 17:16:50 +0000</pubDate>
			<dc:creator>crk</dc:creator>
			<guid isPermaLink="false">30743@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi everyone!&#60;br /&#62;
I have a trouble in using PWM in Maple (r5 with ide 0.0.12)&#60;br /&#62;
The frequency should be 1.1kHz,&#60;br /&#62;
as written here under &#34;Difference 4: PWM frequency&#34;:&#60;br /&#62;
&#60;a href=&#34;http://leaflabs.com/docs/lang/api/analogwrite.html#lang-analogwrite&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/lang/api/analogwrite.html#lang-analogwrite&#60;/a&#62;&#60;br /&#62;
But in each of pwm pin (i tried pin 0 1 2 3 5 6 7 8 9 11 12 14 24 27 28) i have a frequency of 550Hz!&#60;br /&#62;
The delay(), micros() and millis() functions are properly working.&#60;br /&#62;
I have a &#34;faulty&#34; Maple or is there a mistake in the reference page?&#60;br /&#62;
Is it a known issue?&#60;br /&#62;
Anyone had this problem before?&#60;br /&#62;
Thank you
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
