<?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>Setting external GPIO interrupt with the USB dongle</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59143/setting-external-gpio-interrupt-with-the-usb-dongle</link><description>Hi, 
 I&amp;#39;m very new to c programming and your hardware. Please excuse my novice questions. 
 I&amp;#39;m making a rotary braille display using nRF52840 dongle (PCA10059) as it&amp;#39;s brain. The dongle will take interrupt input from phototransistors to trigger braille</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Mar 2020 17:39:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59143/setting-external-gpio-interrupt-with-the-usb-dongle" /><item><title>RE: Setting external GPIO interrupt with the USB dongle</title><link>https://devzone.nordicsemi.com/thread/242173?ContentTypeID=1</link><pubDate>Fri, 27 Mar 2020 17:39:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57889b31-8336-4c09-9a48-5ef4bc0ff1e3</guid><dc:creator>Songpakorn</dc:creator><description>&lt;p&gt;Some&amp;nbsp;more questions.&lt;/p&gt;
&lt;p&gt;I used the wrong encoder input port in the first question they should be 1.10 and 1.13, not 0.10 and 0.13.&lt;/p&gt;
&lt;p&gt;Now even after I corrected the port and enabled pull-up to test pin-to-ground switch, input voltage&amp;nbsp;is&amp;nbsp;always 0. What is wrong now?&lt;/p&gt;
&lt;p&gt;The encoder input from phototransistor is measured between 1.9 to 2.1 V when no-block and blocked respectively. How can I set the pin to detect voltage change event? Which example should I look at?&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting external GPIO interrupt with the USB dongle</title><link>https://devzone.nordicsemi.com/thread/240333?ContentTypeID=1</link><pubDate>Wed, 18 Mar 2020 02:43:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8782610-2455-48ae-9bea-2432b7cfe8f9</guid><dc:creator>Songpakorn</dc:creator><description>&lt;p&gt;Thank you Marjeris,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I put it in main() and then I could measure some changing voltages.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;pca10059.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;
#include &amp;quot;app_button.h&amp;quot;
#include &amp;quot;nrf_sdh.h&amp;quot;

// Rotation sensor inputs
// Encoder trigger
#define ENC_IN      NRF_GPIO_PIN_MAP(0,10)
#define ENC_PULL    NRF_GPIO_PIN_PULLUP
// Direction detect
#define DIR_IN      NRF_GPIO_PIN_MAP(0,13)
#define DIR_PULL    NRF_GPIO_PIN_PULLUP

// Buttons input
//#define BMIDA_IN      NRF_GPIO_PIN_MAP(0,24)
//#define BMIDA_DIR     NRF_GPIO_PIN_DIR_INPUT
//#define BMIDA_PULL    NRF_GPIO_PIN_PULLUP
//#define BMIDB_IN      NRF_GPIO_PIN_MAP(1,00)
//#define BMIDB_DIR     NRF_GPIO_PIN_DIR_INPUT
//#define BMIDB_PULL    NRF_GPIO_PIN_PULLUP
//#define BTHMA_IN      NRF_GPIO_PIN_MAP(0,09)
//#define BTHMA_DIR     NRF_GPIO_PIN_DIR_INPUT
//#define BTHMA_PULL    NRF_GPIO_PIN_PULLUP
//#define BTHMB_IN      NRF_GPIO_PIN_MAP(0,10)
//#define BTHMB_DIR     NRF_GPIO_PIN_DIR_INPUT
//#define BTHMB_PULL    NRF_GPIO_PIN_PULLUP

// Actuator output Right
#define ACT_5       NRF_GPIO_PIN_MAP(0,22)
#define ACT_6       NRF_GPIO_PIN_MAP(0,20)
#define ACT_7       NRF_GPIO_PIN_MAP(0,17)
#define ACT_8       NRF_GPIO_PIN_MAP(0,15)

// Actuator output Left
#define ACT_1       NRF_GPIO_PIN_MAP(0,31)
#define ACT_2       NRF_GPIO_PIN_MAP(0,29)
#define ACT_3       NRF_GPIO_PIN_MAP(0,02)
#define ACT_4       NRF_GPIO_PIN_MAP(1,15)

// Sample Braille Code
// Left column
bool BST_L1[] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
bool BST_L2[] = { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1 };
bool BST_L3[] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
bool BST_L4[] = { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1 };

// Right column
bool BST_R1[] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
bool BST_R2[] = { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1 };
bool BST_R3[] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
bool BST_R4[] = { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1 };

// Define size of braille
size_t bst_len = ARRAY_SIZE(BST_L1);
size_t i = 0;

// Interrupt handler
static void button_handler(uint8_t pin, uint8_t action) {
    // When encoder input is detected rotating to the right
    if (pin == ENC_IN) {
        if (ENC_IN == 0 &amp;amp;&amp;amp; DIR_IN == 0) {
            // Output braille left column
            nrf_gpio_pin_write(ACT_1,BST_L1[i]);
            nrf_gpio_pin_write(ACT_2,BST_L2[i]);
            nrf_gpio_pin_write(ACT_3,BST_L3[i]);
            nrf_gpio_pin_write(ACT_4,BST_L4[i]);
            nrf_gpio_pin_write(ACT_5,0);
            nrf_gpio_pin_write(ACT_6,0);
            nrf_gpio_pin_write(ACT_7,0);
            nrf_gpio_pin_write(ACT_8,0);
            // Direction light Green
            nrf_gpio_pin_write(LED2_G,0);
            nrf_gpio_pin_write(LED2_R,1);
        } else if (ENC_IN == 1 &amp;amp;&amp;amp; DIR_IN == 1) {
            // Output braille right column
            nrf_gpio_pin_write(ACT_1,BST_R1[i]);
            nrf_gpio_pin_write(ACT_2,BST_R2[i]);
            nrf_gpio_pin_write(ACT_3,BST_R3[i]);
            nrf_gpio_pin_write(ACT_4,BST_R4[i]);
            nrf_gpio_pin_write(ACT_5,0);
            nrf_gpio_pin_write(ACT_6,0);
            nrf_gpio_pin_write(ACT_7,0);
            nrf_gpio_pin_write(ACT_8,0);
            // Direction light Red
            nrf_gpio_pin_write(LED2_G,1);
            nrf_gpio_pin_write(LED2_R,0);
            // Index increment, reset if end of string
            i++;
            if (i == bst_len) {
                i = 0;
            }
        }
    }
    // When white button is pushed
    if (pin == BUTTON_1) {
        nrf_gpio_pin_toggle(LED1_G);
    }
}

/**
 * @brief Function for application main entry.
 */
int main() {
    /* Configure board. */
    
    bsp_board_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS);
    nrf_gpio_cfg_input(ENC_IN, ENC_PULL);
    nrf_gpio_cfg_input(DIR_IN, DIR_PULL);
    nrf_gpio_cfg_output(ACT_1);
    nrf_gpio_cfg_output(ACT_2);
    nrf_gpio_cfg_output(ACT_3);
    nrf_gpio_cfg_output(ACT_4);
    nrf_gpio_cfg_output(ACT_5);
    nrf_gpio_cfg_output(ACT_6);
    nrf_gpio_cfg_output(ACT_7);
    nrf_gpio_cfg_output(ACT_8);
    app_timer_init();
    nrf_sdh_enable_request();
    static app_button_cfg_t buttons[] = {
        {ENC_IN, false, ENC_PULL, button_handler},
        {BUTTON_1, false, ENC_PULL, button_handler}
    };
    app_button_init(buttons, ARRAY_SIZE(buttons), 50);
    app_button_enable();
    // Blink the Blue LED if the program is running
    while (true) {
        nrf_gpio_pin_toggle(LED2_B);
        nrf_delay_ms(1000);
    }

}

/**
 *@}
 **/&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Yours,&lt;/p&gt;
&lt;p&gt;Song&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting external GPIO interrupt with the USB dongle</title><link>https://devzone.nordicsemi.com/thread/240321?ContentTypeID=1</link><pubDate>Tue, 17 Mar 2020 18:23:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d57c29c-9df5-4182-affc-e8b843ec5e92</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;see you haven&amp;#39;t configure the pins as output or input pins using &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrf__gpio__hal.html&amp;amp;cp=7_1_6_9_0_13_0_8&amp;amp;anchor=gaefea00d9967a6026bb462d7e183af1f5"&gt;nrf_gpio_cfg_input&lt;/a&gt;&lt;span&gt;() or &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrf__gpio__hal.html&amp;amp;cp=7_1_6_9_0_13_0_9&amp;amp;anchor=ga5c6f584e6e01dd0c65bd1b9eee958cbb"&gt;nrf_gpio_cfg_output&lt;/a&gt;(), this may be the issue.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Marjeris&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>