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

		<item>
			<title>gbulmer on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720&amp;page=2#post-22993</link>
			<pubDate>Wed, 20 Mar 2013 21:52:28 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">22993@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;konan - &#60;em&#62;&#34;PS why vectors[256]? according to RM0008, the last vector offset is 0x12c, so there's only 75 vectors...&#34;&#60;/em&#62;&#60;/p&#62;
&#60;p&#62;I believe that &#60;strong&#62;no&#60;/strong&#62; Cortex-M3 has more than 256 vectors. So that is robust though wasteful :-)&#60;br /&#62;
According to PM0056 rev4, &#60;a href=&#34;http://www.st.com/web/en/resource/technical/document/programming_manual/CD00228163.pdf&#34; rel=&#34;nofollow&#34;&#62;http://www.st.com/web/en/resource/technical/document/programming_manual/CD00228163.pdf&#60;/a&#62;&#60;br /&#62;
there 81 interrupts, so I'd probably use that figure for copying.&#60;/p&#62;
&#60;p&#62;I apologise, I forgot about another complication; the vector table start address must be aligned to 128 bytes, i.e. the bottom 7 bits of the address must be 0, see PM0056 rev4, &#34;4.4.4 Vector table offset register (SCB_VTOR)&#34;.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>konan on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720&amp;page=2#post-22990</link>
			<pubDate>Wed, 20 Mar 2013 14:34:53 +0000</pubDate>
			<dc:creator>konan</dc:creator>
			<guid isPermaLink="false">22990@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Something strange. I tried to copy the VT to the RAM, and give new address to the NVIC, but Maple hangs at boot time. here's the code:&#60;/p&#62;
&#60;p&#62;#include &#34;scb.h&#34;&#60;br /&#62;
#include &#34;nvic.h&#34;&#60;/p&#62;
&#60;p&#62;typedef void (*inthand)(void);&#60;br /&#62;
inthand NVT[75];  // new vector table&#60;/p&#62;
&#60;p&#62;void setup() {&#60;br /&#62;
  inthand *fvt;  // flash vector table&#60;/p&#62;
&#60;p&#62;  fvt = (inthand*)SCB_BASE-&#38;gt;VTOR;&#60;/p&#62;
&#60;p&#62;  for (int i=0; i&#38;lt;75; i++)&#60;br /&#62;
    NVT[i] = *(fvt++);&#60;br /&#62;
  nvic_init((uint32)&#38;amp;NVT, 0);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void loop() {&#60;br /&#62;
  SerialUSB.println((uint32)NVT[55], HEX);&#60;br /&#62;
  delay(1000);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;When I comment out the &#34;nvic_init&#34; line, everything works fine, the value printed to SerialUSB is identical to the value from flash (SCB_BASE-&#38;gt;VTOR+0xDC).
&#60;/p&#62;</description>
		</item>
		<item>
			<title>konan on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720&amp;page=2#post-22988</link>
			<pubDate>Wed, 20 Mar 2013 11:06:50 +0000</pubDate>
			<dc:creator>konan</dc:creator>
			<guid isPermaLink="false">22988@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;gbulmer, thanks again, I'll try this. By the way, about the topic of this thread - I think, copying and modifying the vector table in RAM is much easier way to change any vector we need. It may be done by creating the library, that at start will copy the vector table, and then change any vector(s). With the ability to call &#34;old&#34; irq handlers, using vectors from the original VT in flash.&#60;/p&#62;
&#60;p&#62;PS why vectors[256]? according to RM0008, the last vector offset is 0x12c, so there's only 75 vectors...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720&amp;page=2#post-22987</link>
			<pubDate>Wed, 20 Mar 2013 09:12:55 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">22987@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;konan - If I understood your needs, then you want to have both your interrupt handler, and the 'initial' interrupt handler able to run&#60;/p&#62;
&#60;p&#62;There are, at least, two ways to do this:&#60;br /&#62;
1. Save the initial, in Flash, vector table base address (VTOR), build a new interrupt vector table in RAM (copy the old one and change the entry you want to handle), set the NVIC base register (VTOR) to point to the in-RAM interrupt vector table. Then your interrupt handler does as you describe, using the initial interrupt vector table value when it needs it.&#60;/p&#62;
&#60;p&#62;2. Implement x893's mechanism, described at the head of this thread, for the interrupts you want to override, with the added ability to save previous interrupt vector values when attaching.&#60;/p&#62;
&#60;p&#62;As you have found, VTOR is in the SCB block. According to the ARM document &#34;ARM v7-M Architecture Reference Manual&#34; DDI0403D_arm_architecture_v7m_reference_manual.pdf&#60;br /&#62;
the NVIC vector base register is at 0xE000ED08, so you could grab that value ((unint32**)0xE000ED08) and print the existing vector table. It will have a bunch of values that point to the same interrupt handler. &#60;/p&#62;
&#60;p&#62;So you could allocate an array of uint32's (or void *):&#60;br /&#62;
&#60;code&#62;uint32* vectors[256];&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;copy the flash table to RAM,&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;uint32* flash_vectors = *((unint32**)0xE000ED08);
int i;
for (i=0; i&#38;lt;256; ++i) {
    vectors[i] = *flash_vectors;
    ++flash_vectors;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;set the VTOR to point to the start of it,&#60;br /&#62;
&#60;code&#62;*((unint32**)0xE000ED08) = &#38;amp;vectors[0];&#60;/code&#62;&#60;br /&#62;
and if you got it right, everything should continue to work!-)&#60;/p&#62;
&#60;p&#62;WARNING: THAT CODE IS UNTESTED, NOT EVEN COMPILED.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>konan on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720&amp;page=2#post-22983</link>
			<pubDate>Wed, 20 Mar 2013 01:59:28 +0000</pubDate>
			<dc:creator>konan</dc:creator>
			<guid isPermaLink="false">22983@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;gblumer - thanks for explanation and sorry for late reply :) I holded over that project, but returned to it now. As far as I understood, at boot time the vector table is allocated in flash memory, and the only way to change the single vector is to copy the entire table into RAM, and call nvic_set_vector_table? The original vector table can be found at address from SCB_BASE-&#38;gt;VTOR, am I right?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720&amp;page=2#post-6106</link>
			<pubDate>Sun, 28 Aug 2011 17:28:20 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">6106@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;konan - the mechanism we have described doesn't let you do what you describe directly.&#60;/p&#62;
&#60;p&#62;By providing an interrupt handler called, for example, __irq_adc(), there is no record of the previous interrupt handler; your definition of (in this example) __irq_adc() replaces it completely at link time.&#60;/p&#62;
&#60;p&#62;As many of the handlers are dummy 'do nothing' handlers, this isn't a bad problem.&#60;/p&#62;
&#60;p&#62;There are several ways, some quite involved, of getting an effect similar to the one you describe.&#60;br /&#62;
One involves copying the entire interrupt vector table, at run time into RAM, filling in the address of your handler in the copy, and choosing which interrupt vector table to allow the interrupt hardware to use. &#60;/p&#62;
&#60;p&#62;What is it that you need to do? We might be able to suggest a way to get the result you need.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>konan on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720#post-6073</link>
			<pubDate>Wed, 24 Aug 2011 14:10:36 +0000</pubDate>
			<dc:creator>konan</dc:creator>
			<guid isPermaLink="false">6073@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi all. I have a bit more complex task, than just defining my own handler. Besides of this, in my handler I need to decide, either to use my own routine, or jump to the previously defined handler. So, in setup() function I need to save old handler, and put my handler's address in the vector table. I'm not very familiar with low-level C programming, can anybody give me simple example of how to access the vector table?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720#post-5950</link>
			<pubDate>Tue, 09 Aug 2011 14:07:19 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5950@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi jigajigajoo,&#60;/p&#62;
&#60;p&#62;A good starting point for information on interrupts is the book &#34;The Definitive Guide to the ARM Cortex M3&#34;.  Chapters 7--9 and 11 treat interrupts and exceptions in loving detail.  If you're looking for free documentation, you should probably check out ARM's Cortex M3 Technical Reference Manual, although that's not as easy a read.&#60;/p&#62;
&#60;p&#62;For the structure of a vector table on the STM32, you'll need to check ST's RM0008; see &#60;a href=&#34;http://leaflabs.com/docs/hardware/maple.html#recommended-reading&#34; rel=&#34;nofollow&#34;&#62;http://leaflabs.com/docs/hardware/maple.html#recommended-reading&#60;/a&#62; for links.&#60;/p&#62;
&#60;p&#62;The short story on how libmaple organizes things is that we use linker scripts to weakly define all the IRQ handlers.  This lets you define an IRQ handler as regular function with one of the names given in names.inc (see the other thread you referenced for more info on that file); if you do, the linker picks up on this and uses its address as the corresponding entry in the NVIC.  libmaple defines a variety of these, see e.g. usart.c for examples:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/leaflabs/libmaple/blob/0.0.11/libmaple/usart.c#L233&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple/blob/0.0.11/libmaple/usart.c#L233&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;If neither you nor libmaple provides a definition, the linker uses a default handler (which infinite loops) instead.&#60;/p&#62;
&#60;p&#62;As mentioned above, there's not currently a convenient way to override libmaple's definition, if one exists.  However, luckily for you, adc.c does not define __irq_adc(), so you're free to use your own.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Doc Request - Coretex M3 - Vector Interupt Primer"</title>
			<link>http://forums.leaflabs.com/topic.php?id=40#post-5949</link>
			<pubDate>Tue, 09 Aug 2011 13:55:21 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5949@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;
Is the procedure to setup interrupts on the Maple still valid? I tried to follow the steps... I was trying to get the interrupt from the ADC to work... basically every conversion, the ADC sends an interrupt out to signal a complete conversion.&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;nope.  libmaple has been refactored significantly since the time of those posts.  the names of the weakly-defined IRQ handlers are still given in libmaple's /support/ld/names.inc, but the names have all changed:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;https://github.com/leaflabs/libmaple/blob/0.0.11/support/ld/names.inc&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple/blob/0.0.11/support/ld/names.inc&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;the IRQ handler for ADC1 and ADC2 isn't currently defined by libmaple, so just defining your own (and calling it &#34;__irq_adc&#34;) should do the trick.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jigajigajoo on "Doc Request - Coretex M3 - Vector Interupt Primer"</title>
			<link>http://forums.leaflabs.com/topic.php?id=40#post-5936</link>
			<pubDate>Mon, 08 Aug 2011 15:39:45 +0000</pubDate>
			<dc:creator>jigajigajoo</dc:creator>
			<guid isPermaLink="false">5936@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Is the procedure to setup interrupts on the Maple still valid? I tried to follow the steps... I was trying to get the interrupt from the ADC to work... basically every conversion, the ADC sends an interrupt out to signal a complete conversion.&#60;/p&#62;
&#60;p&#62;I first initialized the ADC (initADC()). I then added an interrupt on the nvic, and the peripheral (in my case the ADC) (initInterrupts()), and then tried to overload the interrupt handlerADC_IRQHandler(). I didn't get it to work.... any input would be invaluable.&#60;/p&#62;
&#60;p&#62;The full code:&#60;br /&#62;
&#60;code&#62;&#60;br /&#62;
// START CONSTANTS&#60;br /&#62;
const uint8 numMics = 6;&#60;br /&#62;
volatile int tic = 0;&#60;/p&#62;
&#60;p&#62;// sampleRate = number of ADC cycles per read = ADC_SMPR_x + 12.5 =&#60;br /&#62;
// samples per cycle at 14 MHz. For ADC_SMPR_1_5, total conversion time = 1 microsec.&#60;br /&#62;
const adc_smp_rate sampleRate = ADC_SMPR_28_5;&#60;br /&#62;
const int       sampleRateInt =          28.5; &#60;/p&#62;
&#60;p&#62;// we're using raw adc channels via adcChans instead of micPins&#60;br /&#62;
const int micPins[6] = {D15, D16, D17, D18, D19, D20};&#60;/p&#62;
&#60;p&#62;// below refers to channels according to ADC docs, and not to pins on maple&#60;br /&#62;
// 10-15 correspond to pins D15-D20 on maple&#60;br /&#62;
// the order of adcChans decides the order in which the channels are read&#60;br /&#62;
// (ie first one = chan0, etc)&#60;br /&#62;
const uint8 adcChans[6] = {10, 11, 12, 13, 14, 15};&#60;/p&#62;
&#60;p&#62;HardwareTimer timer(1);&#60;/p&#62;
&#60;p&#62;// END CONSTANTS&#60;/p&#62;
&#60;p&#62;// Analog input pin.  You may need to change this number if your board&#60;br /&#62;
// can't do analog input on pin 15.&#60;br /&#62;
const int analogStartPin = 15;&#60;/p&#62;
&#60;p&#62;void setup() {&#60;br /&#62;
  // Set up board LED to blink, useful for debugging&#60;/p&#62;
&#60;p&#62;  pinMode(BOARD_LED_PIN, OUTPUT);&#60;br /&#62;
  // Declare analogInputPin as INPUT_ANALOG:&#60;br /&#62;
  for(int i = 0; i &#38;lt; numMics; i++)&#60;br /&#62;
  {&#60;br /&#62;
    pinMode(micPins[i], INPUT_ANALOG);&#60;br /&#62;
  }&#60;br /&#62;
  initADC();&#60;br /&#62;
  initInterrupts();&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void initADC() {&#60;br /&#62;
  // ADC register map&#60;br /&#62;
  adc_reg_map *regs = ADC1-&#38;gt;regs;&#60;/p&#62;
&#60;p&#62;  // below not needed, maplelib does it for us!&#60;br /&#62;
  //adc_init(ADC1);&#60;/p&#62;
&#60;p&#62;  // if adc is on, turn it off so we can change settings&#60;br /&#62;
  if(regs-&#38;gt;CR2 &#124; ADC_CR2_ADON) {&#60;br /&#62;
    regs-&#38;gt;CR2 ^= ADC_CR2_ADON;&#60;br /&#62;
  }&#60;br /&#62;
  adc_set_sample_rate(ADC1, sampleRate);&#60;/p&#62;
&#60;p&#62;  // set number of channels to read&#60;br /&#62;
  adc_set_reg_seqlen(ADC1, numMics);&#60;/p&#62;
&#60;p&#62;  // set channel read sequence order (from adcChans)&#60;br /&#62;
  uint32 channels = 0;&#60;br /&#62;
  for (int i = 0; i &#38;lt; numMics; i++) {&#60;br /&#62;
    channels &#124;= (adcChans[i] &#38;lt;&#38;lt; (i*4));&#60;br /&#62;
  }&#60;br /&#62;
  regs-&#38;gt;SQR3 = channels;&#60;/p&#62;
&#60;p&#62;  // scan mode on&#60;br /&#62;
  regs-&#38;gt;CR1 &#124;= ADC_CR1_SCAN;&#60;/p&#62;
&#60;p&#62;  // continuous mode on&#60;br /&#62;
  regs-&#38;gt;CR2 &#124;= ADC_CR2_CONT;&#60;/p&#62;
&#60;p&#62;  // enable end_of_conversion interrupts&#60;br /&#62;
  regs-&#38;gt;CR1 &#124;= ADC_CR1_EOCIE;&#60;/p&#62;
&#60;p&#62;  // calibrate ADC&#60;br /&#62;
  adc_calibrate(ADC1);&#60;/p&#62;
&#60;p&#62;  // turn on ADC&#60;br /&#62;
  regs-&#38;gt;CR2 &#124;= ADC_CR2_ADON;&#60;/p&#62;
&#60;p&#62;  // start adc read&#60;br /&#62;
  regs-&#38;gt;CR2 &#124;= ADC_CR2_SWSTART;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void initInterrupts() {&#60;br /&#62;
  // enable adc interrupt on the interrupt controller&#60;br /&#62;
  nvic_globalirq_enable();&#60;br /&#62;
  nvic_irq_enable(NVIC_ADC_1_2);&#60;/p&#62;
&#60;p&#62;  //enable adc interrupt on the adc&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;void ADC_IRQHandler(void) {&#60;br /&#62;
  SerialUSB.print('x');&#60;br /&#62;
  tic++;&#60;br /&#62;
  if(tic == 60)&#60;br /&#62;
  {&#60;br /&#62;
    tic = 0;&#60;br /&#62;
    toggleLED();&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;void loop() {&#60;br /&#62;
 // use interrupts!&#60;br /&#62;
}&#60;br /&#62;
&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jigajigajoo on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720#post-5935</link>
			<pubDate>Mon, 08 Aug 2011 14:39:24 +0000</pubDate>
			<dc:creator>jigajigajoo</dc:creator>
			<guid isPermaLink="false">5935@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm interested in learning how to use the ADC interrupts on the Maple, but I'm having a lot of trouble figuring out how to implement them, either in maplelib or higher level stuff.&#60;/p&#62;
&#60;p&#62;Obviously there's the api for external interrupts, but I'm wondering whether there's a way to hook that into the ADC's interrupt.&#60;/p&#62;
&#60;p&#62;More generally, how are interrupts implemented in the ARM architecture? I'm coming from an Arduino and I'm used to supersimple interrupt handling ie&#60;br /&#62;
[code]SIGNAL(TIMER2_OVF_vect) { ... }[/code]&#60;/p&#62;
&#60;p&#62;Is there an equivalent using the maple, or do I have to do something weird with the nvic...&#60;/p&#62;
&#60;p&#62;Also, I found this on the forums, and tried to implement it, but it didn't work for some reason. &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=40&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=40&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720#post-5045</link>
			<pubDate>Tue, 07 Jun 2011 16:27:41 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5045@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;robodude666,&#60;/p&#62;
&#60;p&#62;I had similar thoughts about speeding up timer interrupts in this way.  I agree that allowing advanced users to override the default interrupt handlers is necessary and good.  Thanks for the heads-up about ST's conventions.&#60;/p&#62;
&#60;p&#62;gbulmer,&#60;/p&#62;
&#60;p&#62;Thanks for the links and ideas; that gives me a place to get started.  It does seem more desirable to do this at link time.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720#post-5044</link>
			<pubDate>Tue, 07 Jun 2011 15:25:01 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">5044@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm not sure how efficient you want this.&#60;/p&#62;
&#60;p&#62;For zero overhead, replace the placeholder you've called &#60;code&#62;__irq_tim2&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;I have not written code to check this works with the ARM gcc toolchain.&#60;br /&#62;
A normal linker (ld) would pick up a users implementation of a function before linking in a library implementation.&#60;/p&#62;
&#60;p&#62;Here are two examples which explain how to do this in C on Cortex-M3 (no assembler required):&#60;br /&#62;
&#60;a href=&#34;http://embeddedfreak.wordpress.com/2009/08/07/cortex-m3-interrupt-vector-table/&#34; rel=&#34;nofollow&#34;&#62;http://embeddedfreak.wordpress.com/2009/08/07/cortex-m3-interrupt-vector-table/&#60;/a&#62;&#60;br /&#62;
&#60;a href=&#34;http://dev.frozeneskimo.com/notes/getting_started_with_cortex_m3_cmsis_and_gnu_tools&#34; rel=&#34;nofollow&#34;&#62;http://dev.frozeneskimo.com/notes/getting_started_with_cortex_m3_cmsis_and_gnu_tools&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;So to replace a function defined as&#60;br /&#62;
&#60;code&#62;void __irq_tim2(void);&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;would only need a user to write a function implementation for void __irq_tim2(void):&#60;br /&#62;
&#60;code&#62;void __irq_tim2(void) { ... }&#60;/code&#62;&#60;br /&#62;
compile it, and have it linked before the library.&#60;/p&#62;
&#60;p&#62;Assuming the interrupt table is initialised with the address of &#60;code&#62;void __irq_tim2(void)&#60;/code&#62;, and that table gets loaded by the bootloader, then it's done.&#60;/p&#62;
&#60;p&#62;In some versions of gcc, including the Atmel AVR one, it is very straightforward to define an interrupt handler, and have it 'wired in'.&#60;br /&#62;
Define a function using the syntax:&#60;br /&#62;
&#60;code&#62;SIGNAL(TIMER2_OVF_vect) { ... }&#60;/code&#62;&#60;br /&#62;
where &#60;code&#62;TIMER2_OVF_vect&#60;/code&#62; is a predefined interrupt vector name.&#60;/p&#62;
&#60;p&#62;But, I glanced at the gnu documentation:&#60;br /&#62;
&#60;a href=&#34;http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html&#34; rel=&#34;nofollow&#34;&#62;http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html&#60;/a&#62;&#60;br /&#62;
but that looks like a few generic interrupts only. I think they might be there to support old ARM7 processor states, which don't apply to Cortex-M3.&#60;/p&#62;
&#60;p&#62;This still leaves the problem of how to call a default implementation having just clobbered it by using its name. For a lot of the interrupts, the default is called something like &#60;code&#62;_fail()&#60;/code&#62; and it just loops forever, so straightforward :-)&#60;/p&#62;
&#60;p&#62;So, the documentation of the interrupt handler names, and maybe a code fragment, would be enough.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>robodude666 on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720#post-5041</link>
			<pubDate>Tue, 07 Jun 2011 12:35:42 +0000</pubDate>
			<dc:creator>robodude666</dc:creator>
			<guid isPermaLink="false">5041@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I was browsing the Google Code issue tracker and ran across this ticket and feel what I have to say fits well with changes related to better interrupt APIs.&#60;/p&#62;
&#60;p&#62;In reference to &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=834&#34;&#62;this&#60;/a&#62; thread where an overhead in the timers was brought up, I think it would be cool to see an ability to override the built in interrupt handlers with your own if you desire high-perofmrnace. I really like the way STMicro's Standard Library handles these handlers (no pun intended). They have a single file (stm32f10x_it.h) that contains all of the irq handlers. Something like that would be neat to see for advanced users, or users who require high-performance.&#60;/p&#62;
&#60;p&#62;Going with some of the ideas brought up in this thread I suggest something along the lines of this, taking TIM2's interrupt handler as an example:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;void __irq_tim2(void)
{
#ifdef __IRQ_TIM2_HP_INTERUPT
	if(irq_tim2())
		return;
#endif

    dispatch_general(TIMER2);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;If the user wishes to override the built in handlers, and the overhead incurred by them, they can define &#60;code&#62;__IRQ_TIM2_HP_INTERUPT&#60;/code&#62;. It will then be their responsibility to create a &#60;code&#62;irq_tim2&#60;/code&#62; function in their program. The function will be able to return true (or any non-'false' value) to stop the interrupt from continuing to the built in handlers.&#60;/p&#62;
&#60;p&#62;I'm sure you guys can create better naming and APIs for this, but it's an idea. If the user doesn't want to mess around with the attachInterrupts, the array searching, and rest of the mess invovled with it, they can define a few configuration settings and have a function of a pre-defined name called when the interrupt handler is called. It would be even better if &#60;code&#62;__irq_tim2&#60;/code&#62; could be defined by the user if they wish and save a few more assembly commands per IRQ call.&#60;/p&#62;
&#60;p&#62;-robodude666
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Suggest add attach/detach to all IRQ handler"</title>
			<link>http://forums.leaflabs.com/topic.php?id=720#post-4273</link>
			<pubDate>Mon, 11 Apr 2011 13:45:23 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">4273@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Update: added a bugtracker issue so I don't forget this.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://code.google.com/p/leaflabs/issues/detail?id=62&#38;amp;can=3&#34; rel=&#34;nofollow&#34;&#62;http://code.google.com/p/leaflabs/issues/detail?id=62&#38;amp;can=3&#60;/a&#62;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
