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

		<item>
			<title>mlundinse on "Interrupt Priority"</title>
			<link>http://forums.leaflabs.com/topic.php?id=13467#post-28669</link>
			<pubDate>Mon, 02 Sep 2013 23:54:15 +0000</pubDate>
			<dc:creator>mlundinse</dc:creator>
			<guid isPermaLink="false">28669@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Remember that the STM32F10x processor NVIC only uses 4 (top) bits of priority. So there are really only 16 prority levels: 0x00, 0x10 ... 0xE0, 0xF0
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pyrohaz on "Interrupt Priority"</title>
			<link>http://forums.leaflabs.com/topic.php?id=13467#post-28668</link>
			<pubDate>Mon, 02 Sep 2013 20:27:01 +0000</pubDate>
			<dc:creator>pyrohaz</dc:creator>
			<guid isPermaLink="false">28668@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Ah yes it seems, changing the priority of the Audio interrupt to 2 and the Env interrupt to 1 drastically changes the view on the logic analyzer&#60;/p&#62;
&#60;p&#62;This is with the Env interrupt at higher priority than audio&#60;br /&#62;
&#60;a href=&#34;http://i747.photobucket.com/albums/xx118/hazmatazz/1.png&#34; rel=&#34;nofollow&#34;&#62;http://i747.photobucket.com/albums/xx118/hazmatazz/1.png&#60;/a&#62;&#60;br /&#62;
&#60;a href=&#34;http://i747.photobucket.com/albums/xx118/hazmatazz/2.png&#34; rel=&#34;nofollow&#34;&#62;http://i747.photobucket.com/albums/xx118/hazmatazz/2.png&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Opposite way round&#60;br /&#62;
&#60;a href=&#34;http://i747.photobucket.com/albums/xx118/hazmatazz/3.png&#34; rel=&#34;nofollow&#34;&#62;http://i747.photobucket.com/albums/xx118/hazmatazz/3.png&#60;/a&#62;&#60;br /&#62;
&#60;a href=&#34;http://i747.photobucket.com/albums/xx118/hazmatazz/4.png&#34; rel=&#34;nofollow&#34;&#62;http://i747.photobucket.com/albums/xx118/hazmatazz/4.png&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I think thats problem solved!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pyrohaz on "Interrupt Priority"</title>
			<link>http://forums.leaflabs.com/topic.php?id=13467#post-28667</link>
			<pubDate>Mon, 02 Sep 2013 20:19:44 +0000</pubDate>
			<dc:creator>pyrohaz</dc:creator>
			<guid isPermaLink="false">28667@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi GBulmer, i'll include my whole section of code&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#include &#38;lt;nvic.h&#38;gt;

boolean TBit = 1;

HardwareTimer Audio(1);
HardwareTimer Env(2);

void setup(){
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);

  Audio.pause();
  Env.pause();
  Audio.setOverflow(1499);
  Env.setOverflow(35154);
  Audio.setPrescaleFactor(1);
  Env.setPrescaleFactor(1);
  timer_attach_interrupt(TIMER1, TIMER_UPDATE_INTERRUPT, AudioI);
  timer_attach_interrupt(TIMER2, TIMER_UPDATE_INTERRUPT, EnvI);

  nvic_irq_set_priority(NVIC_TIMER1_UP, 1);
  nvic_irq_set_priority(NVIC_TIMER2, 255);

  Audio.resume();
  Env.resume();
}

void loop(){
  delay(10);
}

void AudioI(){
  gpio_write_bit(GPIOA, 3, TBit);
  TBit=!TBit;
}

void EnvI(){ //Time wasting
  int b = 1;
  for(int a = 1; a&#38;lt;pow(2, 16); a++){
    b*=a;
  }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;What I want is if the EnvI interrupt is being serviced, the ability for the Audio interrupt to fire over it. By watching the timing produced on pin 0 (GPIOA, 3), I can see what form of latency is being introduced. This seems to show some form of time wasting on my logic analyzer and by adding the same bit toggle piece of code to the second interrupt, I can see when that interrupt has finished servicing (if that makes sense) here, changing the interrupt number produces a notable difference and as you say, I think it was the fact that 15 is seen as 0.&#60;/p&#62;
&#60;p&#62;I think thats a problem solved!&#60;br /&#62;
Thanks as per GBulmer.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Interrupt Priority"</title>
			<link>http://forums.leaflabs.com/topic.php?id=13467#post-28666</link>
			<pubDate>Mon, 02 Sep 2013 19:35:18 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">28666@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;pyrohaz - would you please post the fragment of code that is setting priorities?&#60;/p&#62;
&#60;p&#62;Also, try setting the low priority interrupt to 255.&#60;br /&#62;
IIRC, only the &#60;strong&#62;TOP&#60;/strong&#62; 4 bits of each priority value have an effect, and so 15 will look the same as 0.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pyrohaz on "Interrupt Priority"</title>
			<link>http://forums.leaflabs.com/topic.php?id=13467#post-28665</link>
			<pubDate>Mon, 02 Sep 2013 17:34:45 +0000</pubDate>
			<dc:creator>pyrohaz</dc:creator>
			<guid isPermaLink="false">28665@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I'm designing another style of synthesizer using the Maple (absolutely love the chip!).&#60;/p&#62;
&#60;p&#62;I've currently got two interrupts that I want to prioritise. The audio write interrupt where a 16bit variable is placed into the SPI data registor (with a 16bit data frame format) and this section is working fine. This fires at 48kHz. The second interrupt fires at ~2048Hz (reduces division by sample rate to shifts) and is used for the envelope generators. This section of code also works fine. &#60;/p&#62;
&#60;p&#62;The problem is: I want the audio writing interrupt to prioritise over the envelope generator interrupt to reduce audible glitches. I've tried doing this with nvic.h but changing the priority of the timer 1 interrupt to 1 and the timer 2 interrupt to 15 (timer 1 - audio, timer2 - envelope) yet this unfortunately still didn't cause the audio interrupt to fire over the envelope interrupt. To measure this, I've only got a pin toggle in the audio interrupt, in the envelope interrupt, I've got a time consuming section of code (a long for loop).&#60;/p&#62;
&#60;p&#62;After an extremely brief stint with PIC microcontrollers, I know its possible to prioritise interrupts using their set of PIC32 chips, is this possible on the Maple?&#60;/p&#62;
&#60;p&#62;Cheers,
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
