<?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: EXTI not working (libmaple proper)</title>
		<link>http://forums.leaflabs.com/topic.php?id=74454</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:00:33 +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=74454" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105801</link>
			<pubDate>Tue, 10 Nov 2015 15:34:16 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">105801@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@animefreak1233 - Have you found a solution, or any more clues?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105800</link>
			<pubDate>Thu, 29 Oct 2015 21:50:55 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">105800@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@animefreak1233 - &#34;the ISR executes, but only once&#34;? That is weird. Weird is progress :-)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>animefreak1233 on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105799</link>
			<pubDate>Thu, 29 Oct 2015 13:29:12 +0000</pubDate>
			<dc:creator>animefreak1233</dc:creator>
			<guid isPermaLink="false">105799@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;OK, I snooped around the code a bit more, and found out something interesting...&#60;br /&#62;
the ISR executes, but only once&#60;/p&#62;
&#60;p&#62;I'll repost the code&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;if(s &#38;amp; 0x01)
		{

		GPIOB-&#38;gt;regs-&#38;gt;BSRR = (1 &#38;lt;&#38;lt; 1);
		delay_us(1000000);
		GPIOB-&#38;gt;regs-&#38;gt;BRR = (1 &#38;lt;&#38;lt; 1);
		delay_us(1000000);
	}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The above is obviously inside the while loop.&#60;br /&#62;
As for the ISR&#60;br /&#62;
&#60;code&#62;s++;&#60;/code&#62;&#60;br /&#62;
When I let the board boot up and do its stuff, it blinks, but when I press a button, the blinking stops and further presses of the button do nothing&#60;br /&#62;
NOTE: This time, the default value for &#60;code&#62;s&#60;/code&#62; is 1
&#60;/p&#62;</description>
		</item>
		<item>
			<title>animefreak1233 on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105798</link>
			<pubDate>Thu, 29 Oct 2015 13:18:36 +0000</pubDate>
			<dc:creator>animefreak1233</dc:creator>
			<guid isPermaLink="false">105798@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The LED didn't flash
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105797</link>
			<pubDate>Thu, 29 Oct 2015 12:16:30 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">105797@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@animefreak1233 - Okay, so that codes light the LED when the button is pressed, and off when the button is released, yes?&#60;/p&#62;
&#60;p&#62;If so, the question remains about the button triggering the exti interrupt. Yes?&#60;br /&#62;
Have you got a proof for that part already?&#60;/p&#62;
&#60;p&#62;A quick try, which isn't ideal, might be change the if-test in that code in your&#60;br /&#62;
&#60;code&#62;main() { while (1) { if (...) {...} else {...} }}&#60;/code&#62; loop to&#60;br /&#62;
&#60;code&#62;if (s&#38;amp;0x01) { ...} else {...}&#60;/code&#62;&#60;br /&#62;
This will cause the alternative paths to be taken depending on the lowest bit of s&#60;/p&#62;
&#60;p&#62;Then use an ultra simple ISR:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;volatile int s = 0;
void intHandler()
{
    s++;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and attach that ISR.&#60;br /&#62;
This is a bit annoying, because button bounce might cause the LED to switch randomly, but it'd be more useful to know that the interrupt handler is working.&#60;/p&#62;
&#60;p&#62;BTW - when you say &#34;Yes, I tried putting the whole of the while loop inside the EXTI handler, didn't work..&#34;&#60;/p&#62;
&#60;p&#62;Do you mean that it didn't flash, or do you mean other things broke, for example USB got disconnected? It's not important, it was just a way to see if the exti interrupt service routine (ISR) is being called.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>animefreak1233 on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105795</link>
			<pubDate>Thu, 29 Oct 2015 10:39:56 +0000</pubDate>
			<dc:creator>animefreak1233</dc:creator>
			<guid isPermaLink="false">105795@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'll just include the code inside the while loop:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;if(((GPIOB-&#38;gt;regs-&#38;gt;IDR) &#38;amp; (1 &#38;lt;&#38;lt; 8)) == (1 &#38;lt;&#38;lt; 8))//check if the push button reports HIGH
     {
         GPIOB-&#38;gt;regs-&#38;gt;BSRR = (1 &#38;lt;&#38;lt; 1);//Turn on the LED

     }
 else{
         GPIOB-&#38;gt;regs-&#38;gt;BRR = (1 &#38;lt;&#38;lt; 1);//Turn off the LED
     }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The code above is a simple &#34;turn the led ON if the the switch is pressed&#34; code.&#60;br /&#62;
Yes, I tried putting the whole of the while loop inside the EXTI handler, didn't work..&#60;br /&#62;
I've snooped around the libmaple code a bit more and nothing makes me think that my code is wrong. I don't have a hardware debugger for now, so debugging using the HW interface is impossible.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105793</link>
			<pubDate>Wed, 28 Oct 2015 22:19:26 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">105793@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Okay. So, please post the code for &#34;The I/O modes have been set correctly FYI, I verified that by commenting out the EXTI part and simply making a switch-light circuit.&#34;&#60;/p&#62;
&#60;p&#62;I assume that has a few lines of initialisation, and while(1) { ... } which blinks the led, e.g.&#60;br /&#62;
&#60;code&#62;&#60;br /&#62;
		GPIOB-&#38;gt;regs-&#38;gt;BSRR = (1 &#38;lt;&#38;lt; 1);&#60;br /&#62;
                //Turn the LED On&#60;br /&#62;
		delay_us(1000000);&#60;br /&#62;
		GPIOB-&#38;gt;regs-&#38;gt;BRR = (1 &#38;lt;&#38;lt; 1);&#60;br /&#62;
                //Turn the LED Off&#60;br /&#62;
		delay_us(1000000);&#60;br /&#62;
&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Have you tried putting that body of the while loop into an exti interrupt handler, after setting up the handler to be called when the button is pressed?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>animefreak1233 on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105790</link>
			<pubDate>Wed, 28 Oct 2015 14:23:36 +0000</pubDate>
			<dc:creator>animefreak1233</dc:creator>
			<guid isPermaLink="false">105790@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm basically trying to use an EXTI to start blinking an LED whenever the button on the board is pressed. Polling straightly works, using &#60;code&#62;attachInterrupt()&#60;/code&#62; from the wirish framework works, but the low level function doesn't seem to work when I bind it to PB8 (the onboard LED). I've also checked the implementation of the wirish alternative, doesn't seem too different from what I did. The I/O modes have been set correctly FYI, I verified that by commenting out the EXTI part and simply making a switch-light circuit. I'm not using any timers right now, just trying to stretch out in this new architecture after coming from AVRs
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105787</link>
			<pubDate>Tue, 27 Oct 2015 13:42:52 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">105787@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Welcome to the forum.&#60;/p&#62;
&#60;p&#62;Please explain what it is intended to do, and what &#34;my code doesn't work&#34; means.&#60;/p&#62;
&#60;p&#62;Edit:&#60;br /&#62;
Also, have you got some simpler programs which do work. For example, using simple delays and blinking, or polling the timer (repeatedly checking its state in a loop), and blinking. Breaking the problem down into smaller pieces, and posting those might help folks see the problem. Going through that exercise, if you haven't done that already, might also help you see the problem too.&#60;/p&#62;
&#60;p&#62;(Full disclosure: I am not a member of LeafLabs staff.)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>animefreak1233 on "EXTI not working (libmaple proper)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74454#post-105786</link>
			<pubDate>Mon, 26 Oct 2015 16:39:22 +0000</pubDate>
			<dc:creator>animefreak1233</dc:creator>
			<guid isPermaLink="false">105786@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm a 16 yr old self learned hobbyist. I've been banging my head for the last 5 days unable to get the exti part working. Now, I'm gonna come clear, I've twiddled with registers and am using the low level functions and not the wirish library, and for some reason, my code doesn't work...&#60;br /&#62;
Board: Maple mini&#60;br /&#62;
Here's the code:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;#include &#38;lt;libmaple/gpio.h&#38;gt;
#include &#38;lt;libmaple/exti.h&#38;gt;
#include &#38;lt;libmaple/rcc.h&#38;gt;
#include &#38;lt;libmaple/libmaple.h&#38;gt;
//GVars---------------------------------------
volatile int s = 0;
//Functions-----------------------------------
void intHandler();
int main(void){
	RCC_BASE-&#38;gt;APB2ENR &#124;= (1 &#38;lt;&#38;lt; 3);
	//Enabling the clock for PORTB
	GPIOB-&#38;gt;regs-&#38;gt;CRL &#124;= ((1 &#38;lt;&#38;lt; 4)&#124;(1 &#38;lt;&#38;lt; 5));
	GPIOB-&#38;gt;regs-&#38;gt;CRL &#38;amp;= ~((1 &#38;lt;&#38;lt; 7)&#124;(1 &#38;lt;&#38;lt; 6));
        //Setting PB1 (the LED pin) to be an output
	gpio_set_mode(GPIOB, 8, GPIO_INPUT_PD);
        //Setting PB1 (the LED pin) to be an input
	afio_init();
        //Enable the AFIO clock
	//afio_exti_select(AFIO_EXTI_8,AFIO_EXTI_PB);
	exti_attach_interrupt((exti_num)AFIO_EXTI_8, gpio_exti_port(GPIOB), intHandler, EXTI_RISING);
        //attach the interrupt handler to the EXTI9_5 irq
	//Setting PB1 as an OUTPUT
	//blinky
	while(1){
	/*	if((GPIOB-&#38;gt;regs-&#38;gt;IDR &#38;amp; (1 &#38;lt;&#38;lt; 8)) == (1 &#38;lt;&#38;lt; 8))
			s = 1;*/
                if(s == 0)
			continue;
		GPIOB-&#38;gt;regs-&#38;gt;BSRR = (1 &#38;lt;&#38;lt; 1);
                //Turn the LED On
		delay_us(1000000);
		GPIOB-&#38;gt;regs-&#38;gt;BRR = (1 &#38;lt;&#38;lt; 1);
                //Turn the LED Off
		delay_us(1000000);
	}
}
void intHandler()
{
	GPIOB-&#38;gt;regs-&#38;gt;BSRR = (1 &#38;lt;&#38;lt; 1);
    s = 1;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
