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

		<item>
			<title>gbulmer on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7044</link>
			<pubDate>Sat, 29 Oct 2011 16:49:52 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7044@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;newyorkbrass - I think all of those clock outputs suffer the same problem. If it works first time, great, if it doesn't, it will be difficult   to debug (without an oscilloscope or some way of measuring frequency or cycle time).&#60;/p&#62;
&#60;p&#62;I think these things are clear:&#60;br /&#62;
1. A timer can generate either the 18MHz or 24MHz frequency needed&#60;br /&#62;
2. at either frequency it can be equal mark space ratio&#60;br /&#62;
3. at 18MHz, it can generate symmetric PWM&#60;br /&#62;
4. by simply shifting the prescaler, overflow and pwm values, it is practical to make the timing of the wave form so clear to human perception that it can be measured and verified with a watch, and then speeded up to the frequency needed.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>newyorkbrass on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7042</link>
			<pubDate>Sat, 29 Oct 2011 14:22:43 +0000</pubDate>
			<dc:creator>newyorkbrass</dc:creator>
			<guid isPermaLink="false">7042@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;OOOPS. connectivity line&#60;br /&#62;
This is the correct one:&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
Clock-out capability&#60;br /&#62;
The microcontroller clock output (MCO) capability allows the clock to be output onto the&#60;br /&#62;
external MCO pin. The configuration registers of the corresponding GPIO port must be&#60;br /&#62;
programmed in alternate function mode. One of 4 clock signals can be selected as the MCO&#60;br /&#62;
clock.&#60;br /&#62;
● SYSCLK&#60;br /&#62;
● HSI&#60;br /&#62;
● HSE&#60;br /&#62;
● PLL clock divided by 2
&#60;/p&#62;&#60;/blockquote&#62;</description>
		</item>
		<item>
			<title>newyorkbrass on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7041</link>
			<pubDate>Sat, 29 Oct 2011 12:05:09 +0000</pubDate>
			<dc:creator>newyorkbrass</dc:creator>
			<guid isPermaLink="false">7041@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I read the docs again: &#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
The microcontroller clock output (MCO) capability allows the clock to be output onto the&#60;br /&#62;
external MCO pin. The configuration registers of the corresponding GPIO port must be&#60;br /&#62;
programmed in alternate function mode. One of 8 clock signals can be selected as the MCO&#60;br /&#62;
clock.&#60;br /&#62;
● SYSCLK&#60;br /&#62;
● HSI&#60;br /&#62;
● HSE&#60;br /&#62;
● PLL clock divided by 2 selected&#60;br /&#62;
● PLL2 clock selected&#60;br /&#62;
● PLL3 clock divided by 2 selected&#60;br /&#62;
● XT1 external 3-25 MHz oscillator clock selected (for Ethernet)&#60;br /&#62;
● PLL3 clock selected (for Ethernet)&#60;br /&#62;
The selected clock to output onto MCO must not exceed 50 MHz (the maximum I/O speed).&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;So I guess your right except i am using the wrong MCO out, I should be using: &#34;PLL3 clock selected (for Ethernet)&#34; that will output 25MHz
&#60;/p&#62;</description>
		</item>
		<item>
			<title>newyorkbrass on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7040</link>
			<pubDate>Sat, 29 Oct 2011 12:01:44 +0000</pubDate>
			<dc:creator>newyorkbrass</dc:creator>
			<guid isPermaLink="false">7040@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I want to connect two PixArt Wii cameras to the maple and it needs a 16-25MHz clock. Doing this would allow direct interfacing of the maple to the camera. The The HSE is 8MHz but according to documentation I understand I can use a PLL to generate that frequency. Just dont want to break anything else in the system on the way :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7037</link>
			<pubDate>Sat, 29 Oct 2011 06:39:00 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7037@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;newyorkbrass - not sure how that gets you a symmetric 18MHz, or 20 to 25MHz square wave.&#60;br /&#62;
On a Maple, the crystal is 8MHz. &#60;/p&#62;
&#60;p&#62;What are you actually trying to achieve?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>newyorkbrass on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7035</link>
			<pubDate>Sat, 29 Oct 2011 02:28:08 +0000</pubDate>
			<dc:creator>newyorkbrass</dc:creator>
			<guid isPermaLink="false">7035@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;found a better solution: &#60;/p&#62;
&#60;p&#62;I found how to output the HSE clock as a peripheral on pin 6 (GPIOA 8):&#60;/p&#62;
&#60;p&#62;I combined some stuff from the &#34;official&#34; libraries and the ones in libmaple:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
#define RCC_MCO_HSE                      ((unsigned char)0x06)&#60;/p&#62;
&#60;p&#62;//typedef volatile unsigned char  vu8;&#60;br /&#62;
  /* CFGR register byte 4 (Bits[31:24]) base address */&#60;/p&#62;
&#60;p&#62;#define CFGR_BYTE4_ADDRESS        ((unsigned int)0x40021007)&#60;/p&#62;
&#60;p&#62;void RCC_MCOConfig(volatile unsigned char RCC_MCO)&#60;br /&#62;
{&#60;br /&#62;
  /* Check the parameters */&#60;/p&#62;
&#60;p&#62;  /* Perform Byte access to MCO[2:0] bits to select the MCO source */&#60;br /&#62;
  *(volatile unsigned char *) CFGR_BYTE4_ADDRESS = RCC_MCO;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;then in the init:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;&#60;br /&#62;
  rcc_clk_enable(RCC_GPIOA);&#60;br /&#62;
  gpio_set_mode( GPIOA, 8, GPIO_OUTPUT_PP );&#60;br /&#62;
  RCC_MCOConfig(RCC_MCO_HSE);&#60;br /&#62;
&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;This &#60;strong&#62;should&#60;/strong&#62; work .... :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7025</link>
			<pubDate>Fri, 28 Oct 2011 15:40:33 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">7025@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;newyorkbrass - you could make it easy to measure the actual cycle time by using scale factors to get big values for prescaler and overflow, and scale the pwm value to match it. Then you can time the signal by flashing an LED and using a watch, no oscilloscope needed.&#60;/p&#62;
&#60;p&#62;So&#60;br /&#62;
- prescaler is (1 &#38;lt;&#38;lt; 16)&#60;br /&#62;
- overflow (4 &#38;lt;&#38;lt; 10)&#60;br /&#62;
- pwm(14, (2 &#38;lt;&#38;lt; 10))&#60;br /&#62;
would be 2^(16+10) times slower = 67,108,864 times slower.&#60;br /&#62;
If the unshifted values are correct for 18MHz, the cycle time for these shifted values should be about 3.7 seconds, and if the values are wrong, the error will be about 1/4 of that, or about 0.9 seconds which should be plainly visible.&#60;/p&#62;
&#60;p&#62;I think you'll find the values you've chosen are too big for a symmetric PWM signal.&#60;br /&#62;
When the PWM signal is symmetric, it takes two PWM-counter cycles for each  signal cycle. The counter counts up, then down to make a single PWM pulse. So the prescale value will need to be halved (which it can't be, it is one), or the overflow value and PWM value will need to be halved.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bart_dood on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7022</link>
			<pubDate>Fri, 28 Oct 2011 01:03:37 +0000</pubDate>
			<dc:creator>bart_dood</dc:creator>
			<guid isPermaLink="false">7022@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Yes I believe that is correct.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>newyorkbrass on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7017</link>
			<pubDate>Thu, 27 Oct 2011 10:36:26 +0000</pubDate>
			<dc:creator>newyorkbrass</dc:creator>
			<guid isPermaLink="false">7017@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;specifically: would this work? would this give 18MHz? unfortunately I dont have access to an oscilloscope :(&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;code&#38;gt;
   pinMode(14,PWM);
    timer.setPrescaleFactor(1);
    timer.setOverflow(4);
    pwmWrite(14, 2);
&#38;lt;/code&#38;gt;&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>newyorkbrass on "20-25MHz clock on a gpio pin"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1137#post-7015</link>
			<pubDate>Thu, 27 Oct 2011 09:47:13 +0000</pubDate>
			<dc:creator>newyorkbrass</dc:creator>
			<guid isPermaLink="false">7015@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Has anyone used a PWM to generate a 20 to 25 MHz clock on one of the GPIO pins? how would I be able to get a symmetric clock?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
