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

		<item>
			<title>gbulmer on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2163</link>
			<pubDate>Tue, 02 Nov 2010 20:05:52 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">2163@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;For more juicy goodness on the ARM Cortex M-3 interrupts, check out &#60;a href=&#34;http://www.drdobbs.com/blog/archives/2010/10/arm_cortex_m3_p_1.html&#34; rel=&#34;nofollow&#34;&#62;http://www.drdobbs.com/blog/archives/2010/10/arm_cortex_m3_p_1.html&#60;/a&#62;&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;The author seems to misunderstand M0 to M4&#60;br /&#62;
Also&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;With Thumb-2, everything can be done in 16-bit instruction mode.&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Thumb-2 has both 16 bit and 32 bit instructions.&#60;/p&#62;
&#60;p&#62;There are also  statements which I read as contradictory:&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;there is a very small and deterministic interrupt latency (12 cycles or less from normal code to interrupt handler)&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;For interrupt latency to be deterministic if must be the same number of cycles, i.e. &#34;12 cycles from normal code to interrupt handler&#34;.&#60;br /&#62;
It is either deterministic interrupt latency, or it is &#34;12 cycles or less&#34;, but I don't see how it can be both.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;ST divides the STM32 into Performance and Access lines
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;No, they divide STM32F into five lines &#60;a href=&#34;http://www.st.com/mcu/inchtml-pages-stm32.html&#34;&#62;Connectivity, Performance, USB Access, Access, Value&#60;/a&#62;&#60;br /&#62;
and STM32 into even more under the three families &#60;a href=&#34;http://www.st.com/mcu/inchtml-pages-stm32_platform.html&#34;&#62;STM32F - 32-bit ARM Cortex MCUs , STM32L - 32-bit ultra-low-power MCUs, STM32W - 32-bit ARM Cortex RF MCUs&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I wouldn't recommend folks read the article, unless you have the energy to help the author clarify statements and correct the errors.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>larryang on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2156</link>
			<pubDate>Tue, 02 Nov 2010 10:27:52 +0000</pubDate>
			<dc:creator>larryang</dc:creator>
			<guid isPermaLink="false">2156@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;For more juicy goodness on the ARM Cortex M-3 interrupts, check out &#60;a href=&#34;http://www.drdobbs.com/blog/archives/2010/10/arm_cortex_m3_p_1.html&#34; rel=&#34;nofollow&#34;&#62;http://www.drdobbs.com/blog/archives/2010/10/arm_cortex_m3_p_1.html&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;It supports 255 interrupts.  It looks like you won't need to disable interrupts, as you can prioritize and nest them.  But if you really need to deal with multiple interrupts, I would suggest an RTOS.  &#60;/p&#62;
&#60;p&#62;Latency snippet below:&#60;/p&#62;
&#60;p&#62;&#34;[...] (12 cycles or less from normal code to interrupt handler). The worst case latency is when a low priority interrupt occurs while a higher priority interrupt is preparing to return to the main program. In this case the latency could be as high as 18 cycles. However, if the lower priority interrupt occurs during the high priority interrupts handle, the NVIC adds the new interrupt to the end of the original interrupt so there is only a 6 cycle gap between the two handlers. Of course, when using nested interrupts, the latency will probably largely be determined by the length of your interrupt handlers (except, of course, for the highest priority interrupt).&#34;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2153</link>
			<pubDate>Mon, 01 Nov 2010 20:48:38 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">2153@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;gbulmer - not yet. i'll ping the relevant people to see if they have anything worth putting in a branch.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2149</link>
			<pubDate>Mon, 01 Nov 2010 17:27:35 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">2149@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;mbolivar - is there any DMA code in github yet?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2143</link>
			<pubDate>Mon, 01 Nov 2010 13:53:08 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">2143@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;on the subject of DMA: right now, you'll have to do it yourself; i.e., there's no libmaple support for it, so you'll need to take a look at ST's manuals and set the registers by hand.  it's being actively worked on, however.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2128</link>
			<pubDate>Sat, 30 Oct 2010 17:21:09 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">2128@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;DMA - Wikipedia says: &#60;a href=&#34;http://en.wikipedia.org/wiki/Direct_memory_access&#34;&#62;Direct memory access&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Quick quote from Wikipedia:&#60;br /&#62;
&#34;Direct memory access (DMA) is a feature of modern computers and microprocessors that allows certain hardware subsystems within the computer to access system memory for reading and/or writing independently of the central processing unit.&#34;&#60;/p&#62;
&#60;p&#62;As a concrete example, lets imagine that you'd like to get the value from a peripheral register, and put it into memory, every time an interrupt fires. This is a very straightforward job, and doesn't really need all the power of the processor.&#60;/p&#62;
&#60;p&#62;Lets write some pseudo-code (almost C, but I might skip some details) to do that&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;int32 *peripheral_register_src = 0x...;
  int32 memory[10];
  int32 *memory_dest = &#38;amp;memory[0];
  attachDMAinterrupt(peripheral_register_interrupt, move_peripheral_register);
  ....

void move_peripheral_register() {
  *memory_dest++ = *peripheral_register_src;
  if (memory_dest &#38;gt;= &#38;amp;memory[10]) {
    raise an interrupt for the processor
  }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;A DMA controller does the piece in the &#60;code&#62;move_peripheral_register&#60;/code&#62; interrupt handler, without involving the processor unless it runs beyond the end of its allocated memory block. &#60;/p&#62;
&#60;p&#62;I hope that makes sense.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>IIIIIIIIII on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2121</link>
			<pubDate>Sat, 30 Oct 2010 11:02:06 +0000</pubDate>
			<dc:creator>IIIIIIIIII</dc:creator>
			<guid isPermaLink="false">2121@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thank you so much, this is exactly what I needed to know. I didn't see that each pin had a capture register when I looked through the processor datasheet, and that makes what I want to do so much easier. I was thinking there was a single register that I'd have to get the data from before the next event. Also, what is this DMA you mentioned, I don't think I'm familiar with the term. &#60;/p&#62;
&#60;p&#62;Looks like I need to go order a Maple board. I've been looking to get one for a while and now I finally have a good reason. Thanks so much you guys!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2112</link>
			<pubDate>Fri, 29 Oct 2010 07:46:37 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">2112@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;
There is also a USB connection. I'm not sure if there is anything that needs to be done about this. Maybe a LeafLabs person can answer.
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Yup, USB will fire a high-priority interrupt every 5ms by default.  You can disable it in software. We had to do this (along with disabling SysTick) in a project to get the Maple to drive VGA smoothly; without this, the timing was nondeterministic enough to cause display artifacts.  Here's some example code:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://github.com/leaflabs/projects/blob/14b624b6ac961887d8dfa07b9d8b6be840c9c82d/vga-colors/main.cpp#L298&#34; rel=&#34;nofollow&#34;&#62;http://github.com/leaflabs/projects/blob/14b624b6ac961887d8dfa07b9d8b6be840c9c82d/vga-colors/main.cpp#L298&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2100</link>
			<pubDate>Thu, 28 Oct 2010 19:34:40 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">2100@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;Does anybody know the overhead on the external interrupt feature? I'm looking for a microcontroller for a research project, and I need accurate timing on the order of microseconds.&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;The STM32F manuals at &#60;a href=&#34;http://www.st.com/mcu/familiesdocs-110.html&#34;&#62;http://www.st.com/mcu/familiesdocs-110.html&#60;/a&#62;&#60;br /&#62;
will give these answers in loving detail.&#60;/p&#62;
&#60;p&#62;Essentially, the ARM Cortex-M3 has been designed to give deterministic interrupt response times, so, in the absence of multiple interrupts, the times should be very predictable.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;know I could do this on a hardware level, I've done similar things in assembly code on different boards, however I'd much rather use C in a user friendly environment like on the maple.
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Pretty much everything on a Maple (ARM Cortex-M3) is programmed in C, no assembler required. All peripherals and I/O pins are accessed in C. (This is a key advantage of ARM Cortex-M3 over some earlier generations of ARM)&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;What I essentially need is to be able to record the exact time an interrupt occurs relative to other interrupts. Basically there will be a half dozen events or so happening potentially within a 30us time frame, and I need to know when they happened relative to each other.&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Is it just &#60;em&#62;one&#60;/em&#62; set of 6 interrupts, or are there many sets of 6 interrupts?&#60;br /&#62;
That may have a bearing on the approach.&#60;/p&#62;
&#60;p&#62;You said there are only half a dozen signals.&#60;br /&#62;
In that case you could use timers configured to use their input capture pins.&#60;/p&#62;
&#60;p&#62;The Maple has four timers, each timer has 4 channels, and each channel has an input capture pin which controls a 'capture register'. So up to 16 input pins can be used to time 16 external signals (I'd need to go check how many of those are available on the Maples 64 pin part, but many more than 6)&#60;/p&#62;
&#60;p&#62;When an input capture pin gets a signal, it copies the timer's current counter value into its 'capture register'.&#60;br /&#62;
The timer can run at upto 72MHz, so you'd get significantly better resolution than 1uS.&#60;/p&#62;
&#60;p&#62;The timer's capture event can simultaneously trigger interrupts, but this is a bit easier than dealing with getting the time in your interrupt handler, as the code just needs to copy the value from the capture register to memory.&#60;/p&#62;
&#60;p&#62;(It is possible to have the DMA system put the values into memory, so there is only one interrupt to worry about, i.e. when all 6 values have been captured, but one thing at a time :-)&#60;/p&#62;
&#60;p&#62;If you switch off interrupts, the processor could miss one, and an event would be lost. Is this okay?&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;If I use an external interrupt will it immediately execute my code?&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;That depends on whether or not interrupts are disabled, and if there is a higher priority interrupt running. If interrupts are disabled, no, it won't execute your code. If there is a higher priority interrupt the lower priority must wait until the higher priority interrupt handler exits.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Are there any automatic maintenance routines that would delay only one interrupt?&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Yes, there is a millisecond timer which would have to be switched off, which you can do  in software. &#60;/p&#62;
&#60;p&#62;There is also a USB connection. I'm not sure if there is anything that needs to be done about this. Maybe a LeafLabs person can answer.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Any other issues you can think of off-hand?&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Certainly start by doing it in software, to get the feel of the system. But be prepared to dig into timers if it is important that it is very accurate and predicable.&#60;/p&#62;
&#60;p&#62;Other than suggesting you don't do this in software, but instead let the hardware timers do the job for you, I can't think of any other issues.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>IIIIIIIIII on "External Interrupt questions"</title>
			<link>http://forums.leaflabs.com/topic.php?id=271#post-2099</link>
			<pubDate>Thu, 28 Oct 2010 18:38:44 +0000</pubDate>
			<dc:creator>IIIIIIIIII</dc:creator>
			<guid isPermaLink="false">2099@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Does anybody know the overhead on the external interrupt feature? I'm looking for a microcontroller for a research project, and I need accurate timing on the order of microseconds. &#60;/p&#62;
&#60;p&#62;What I essentially need is to be able to record the exact time an interrupt occurs relative to other interrupts. Basically there will be a half dozen events or so happening potentially within a 30us time frame, and I need to know when they happened relative to each other. &#60;/p&#62;
&#60;p&#62;What I'm thinking is when an external interrupt occurs, have the microcontroller disable interrupts, record the value in one of the timers to memory, then re-enable interrupts. This couldn't take too many clock cycles so I think it would work, especially since the overhead before it records the timer's value should be exactly the same for each interrupt. With the timer prescaler set to have it tick once a microsecond I should be able to get fairly accurate measurements. At least I think so.&#60;/p&#62;
&#60;p&#62;I know I could do this on a hardware level, I've done similar things in assembly code on different boards, however I'd much rather use C in a user friendly environment like on the maple. If I use an external interrupt will it immediately execute my code? Are there any automatic maintenance routines that would delay only one interrupt? Any other issues you can think of off-hand?&#60;/p&#62;
&#60;p&#62;Thanks in advance.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
