<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11148/external-interrupt-on-nrf51822</link><description>hello there i want to generate external interrupt from adxl345.can you help me? can we do same like we are using with button??</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 15 Jan 2016 14:36:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11148/external-interrupt-on-nrf51822" /><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41785?ContentTypeID=1</link><pubDate>Fri, 15 Jan 2016 14:36:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbcf937f-3a66-44cd-8c8b-80c62ffb2c7e</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;i don&amp;#39;t know but this code is not working. when i load this code. all LEDS are on. there is no change in LED. if i press button&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41784?ContentTypeID=1</link><pubDate>Fri, 15 Jan 2016 14:34:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33542467-56cb-45a0-9ae6-629bed31c790</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;app_button.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_gpiote.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define APP_TIMER_PRESCALER             0  // Value of the RTC1 PRESCALER register.
#define APP_TIMER_MAX_TIMERS            1  // Maximum number of simultaneously created timers. 
#define APP_TIMER_OP_QUEUE_SIZE         2  // Size of timer operation queues. 
#define BUTTON_DEBOUNCE_DELAY			50 // Delay from a GPIOTE event until a button is reported as pushed. 
#define APP_GPIOTE_MAX_USERS            1  // Maximum number of users of the GPIOTE handler. 

/*
 * Handler to be called when button is pushed.
 * param[in]   pin_no 			The pin number where the event is genereated
 * param[in]   button_action 	Is the button pushed or released
 */
static void button_handler(uint8_t pin_no, uint8_t button_action)
{
    if(button_action == APP_BUTTON_PUSH)
    {
        switch(pin_no)
        {
            case BUTTON_1:
                nrf_gpio_pin_toggle(LED_1);
                break;
            case BUTTON_2:
                nrf_gpio_pin_toggle(LED_2);
                break;
            case BUTTON_3:
                nrf_gpio_pin_toggle(LED_3);
                break;
            case BUTTON_4:
                nrf_gpio_pin_toggle(LED_4);
                break;
            default:
                break;
        }
    }
}

/**
 * Initialize the clock.
 */
void init_clock()
{
    NRF_CLOCK-&amp;gt;LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_Xtal &amp;lt;&amp;lt; CLOCK_LFCLKSRC_SRC_Pos);
    NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_LFCLKSTART    = 1;
    while (NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED == 0); // Wait for clock to start
}	

/**
 * Initialize all four LEDs on the nRF51 DK.
 */
void init_leds()
{
    nrf_gpio_cfg_output(LED_1);
    nrf_gpio_cfg_output(LED_2);
    nrf_gpio_cfg_output(LED_3);
    nrf_gpio_cfg_output(LED_4);
    nrf_gpio_pin_set(LED_1);
    nrf_gpio_pin_set(LED_2);
    nrf_gpio_pin_set(LED_3);
    nrf_gpio_pin_set(LED_4);
}	

/**
 * Function for application main entry.
 */
int main(void)
{	
    init_leds();
    init_clock();

    uint32_t err_code;

    // Button configuration structure.
    static app_button_cfg_t p_button[] = {  {BUTTON_1, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                            {BUTTON_2, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                            {BUTTON_3, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler},
                                            {BUTTON_4, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}};
        
    // Macro for initializing the application timer module.
    // It will handle dimensioning and allocation of the memory buffer required by the timer, making sure that the buffer is correctly aligned. It will also connect the timer module to the scheduler (if specified).
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);

    // Macro for initializing the GPIOTE module.
    // It will handle dimensioning and allocation of the memory buffer required by the module, making sure that the buffer is correctly aligned.
    APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);

    // Initializing the buttons.
    err_code = app_button_init(p_button, sizeof(p_button) / sizeof(p_button[0]), BUTTON_DEBOUNCE_DELAY);
    APP_ERROR_CHECK(err_code);
                                            
    // Enabling the buttons.										
    err_code = app_button_enable();
    APP_ERROR_CHECK(err_code);

    while(true)
    {
        // Do nothing.
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41783?ContentTypeID=1</link><pubDate>Fri, 15 Jan 2016 14:19:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9b69a00-ed06-4bd0-b3db-5e6e6aa65883</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;this is not working&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41782?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 08:14:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7af12aa0-9a0b-4c1b-9d8c-ac420edabb6a</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;can i use above button event handler function i have written above??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41781?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 08:13:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3783f4d7-1a5e-4afd-9231-ab0415cd7d8c</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;ok i will try it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41780?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 08:13:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6d6e99c-1678-4886-a852-f51d02a5e0ee</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;i am using nrf51 SDK10&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41779?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2016 16:04:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:216ab951-d1ad-421d-be4c-7a7d10d936c0</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi rushin&lt;/p&gt;
&lt;p&gt;Would &lt;a href="https://devzone.nordicsemi.com/question/62815/gpio-does-not-sense-button-press/"&gt;this button press solution&lt;/a&gt; be useful to you, or do you want to use app_button directly?&lt;/p&gt;
&lt;p&gt;By the way, what nRF51 SDK version are you using?&lt;/p&gt;
&lt;p&gt;All that a button does is to change the voltage level on a GPIO pin to generate an interrupt. If an external circuit also changes the voltage level in the same way as a button does, you can use the same button code to detect an interrupt from an external circuit, as e.g. the adxl345.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 8.1.2016&lt;/strong&gt;
To use app_button, you need to initialize app_timer and app_gpiote, because app_button uses those libraries internally. A good app_button code example is available on &lt;a href="https://github.com/NordicSemiconductor/nrf51-app-button-example"&gt;Github&lt;/a&gt;. The example is for nRF51 SDK 8.0.0 but it should also work for nRF51 SDK 10.0.0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41778?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2016 06:11:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd097ae9-ed27-4323-9267-165cbb7979cb</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;i can&amp;#39;t solve my this doubt. can anyone help me??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41777?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2016 15:29:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db413f74-7271-4277-a27a-85209dbaca76</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;i think this code is useful for me.but i can&amp;#39;t understand it. can anyone explain me  how button_event_handler is used in buttons init function??&lt;/p&gt;
&lt;p&gt;here they don&amp;#39;t use two arguments like uint8_t pin_no, uint8_t button_action.
can anyone explain me??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: external interrupt on nrf51822</title><link>https://devzone.nordicsemi.com/thread/41776?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2016 15:25:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b952e30f-8b61-4ffe-be65-2712007ea184</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    static void button_event_handler(uint8_t pin_no, uint8_t button_action)    
    {    
        uint32_t err_code;    

        switch (pin_no)
        {
            case LEDBUTTON_BUTTON_PIN:
                err_code = ble_lbs_on_button_change(&amp;amp;m_lbs, button_action);
                if (err_code != NRF_SUCCESS &amp;amp;&amp;amp;
                    err_code != BLE_ERROR_INVALID_CONN_HANDLE &amp;amp;&amp;amp;
                    err_code != NRF_ERROR_INVALID_STATE)
                {
                    APP_ERROR_CHECK(err_code);
                }
                break;

            default:
                APP_ERROR_HANDLER(pin_no);
                break;
        }
    }


    /**@brief Function for initializing the button handler module.
     */
    static void buttons_init(void)
    {
        uint32_t err_code;

        //The array must be static because a pointer to it will be saved in the button handler module.
        static app_button_cfg_t buttons[] =
        {
            {LEDBUTTON_BUTTON_PIN, false, BUTTON_PULL, button_event_handler}
        };

        err_code = app_button_init(buttons, sizeof(buttons) / sizeof(buttons[0]),
                               BUTTON_DETECTION_DELAY);
        APP_ERROR_CHECK(err_code);
    }
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>