<?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>Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111/assigning-a-functional-block-to-a-gpio</link><description>I&amp;#39;m confused about how to assign a functional block&amp;#39;s I/O (TWI in my case) to a particular pin on the device. Is there a worked and documented example? Is there a relevant application note?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Aug 2013 10:59:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111/assigning-a-functional-block-to-a-gpio" /><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/620?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2013 10:59:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e828194f-4181-4284-9ea4-e51f84017fa3</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;This sounds like you&amp;#39;re not using the softdevice functions for manipulating the PPI. Please see this answer:
&lt;a target="_blank" href="https://devzone.nordicsemi.com/index.php/twi-on-nrf51822#reply-239" rel="nofollow"&gt;https://devzone.nordicsemi.com/index.php/twi-on-nrf51822#reply-239&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/619?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 14:15:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3058d0c-f330-452c-8adb-64ea1de57bcb</guid><dc:creator>sd</dc:creator><description>&lt;p&gt;Hi again. Since I&amp;#39;ve used the template design as, well, my template, I had all the following init calls intact:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    // Initialize
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
    ble_stack_init();
    scheduler_init();
    gap_params_init();
    advertising_init();
    services_init();
    conn_params_init();
    sec_params_init();
    
    // Start execution
    timers_start();
    advertising_start();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That caused the twi_init() call to hang. However, if I comment out some of these calls, like so:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    // Initialize
    leds_init();
    timers_init();
    gpiote_init();
    buttons_init();
//    ble_stack_init();
    scheduler_init();
//    gap_params_init();
//    advertising_init();
    services_init();
//    conn_params_init();
    sec_params_init();
    
    // Start execution
    timers_start();
//    advertising_start();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I see the clock running on the TWI SCK pin! Any hints on why this happens on how to resolve these potential conflicts? Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/618?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 13:49:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00b7dfb2-12d2-43f6-ba44-3da51168e5cc</guid><dc:creator>sd</dc:creator><description>&lt;p&gt;I&amp;#39;ve narrowed it down to the chip getting stuck when I call this function (it&amp;#39;s unmodified from the example code):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bool twi_master_init(void)
{
    /* To secure correct signal levels on the pins used by the TWI
       master when the system is in OFF mode, and when the TWI master is 
       disabled, these pins must be configured in the GPIO peripheral.
    */
    NRF_GPIO-&amp;gt;PIN_CNF[TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER] = 
        (GPIO_PIN_CNF_SENSE_Disabled &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)
      | (GPIO_PIN_CNF_DRIVE_S0D1     &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos)
      | (GPIO_PIN_CNF_PULL_Pullup    &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)
      | (GPIO_PIN_CNF_INPUT_Connect  &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos)
      | (GPIO_PIN_CNF_DIR_Input      &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);    

    NRF_GPIO-&amp;gt;PIN_CNF[TWI_MASTER_CONFIG_DATA_PIN_NUMBER] = 
        (GPIO_PIN_CNF_SENSE_Disabled &amp;lt;&amp;lt; GPIO_PIN_CNF_SENSE_Pos)
      | (GPIO_PIN_CNF_DRIVE_S0D1     &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos)
      | (GPIO_PIN_CNF_PULL_Pullup    &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos)
      | (GPIO_PIN_CNF_INPUT_Connect  &amp;lt;&amp;lt; GPIO_PIN_CNF_INPUT_Pos)
      | (GPIO_PIN_CNF_DIR_Input      &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);    

    NRF_TWI1-&amp;gt;EVENTS_RXDREADY = 0;
    NRF_TWI1-&amp;gt;EVENTS_TXDSENT = 0;
    NRF_TWI1-&amp;gt;PSELSCL = TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER;
    NRF_TWI1-&amp;gt;PSELSDA = TWI_MASTER_CONFIG_DATA_PIN_NUMBER;
    NRF_TWI1-&amp;gt;FREQUENCY = TWI_FREQUENCY_FREQUENCY_K100 &amp;lt;&amp;lt; TWI_FREQUENCY_FREQUENCY_Pos;
    NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t)&amp;amp;NRF_TWI1-&amp;gt;EVENTS_BB;
    NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_TWI1-&amp;gt;TASKS_SUSPEND;
    NRF_PPI-&amp;gt;CHENCLR = PPI_CHENCLR_CH0_Msk;
    NRF_TWI1-&amp;gt;ENABLE = TWI_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; TWI_ENABLE_ENABLE_Pos;

    return twi_master_clear_bus();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What I see is the pins going high, as they should, but nothing more. What am I missing?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/613?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 13:41:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffddb1d3-5069-471c-bc8b-b63cebd11b28</guid><dc:creator>sd</dc:creator><description>&lt;p&gt;Sorry, I can&amp;#39;t post the code right now on the forum.&lt;/p&gt;
&lt;p&gt;No, I&amp;#39;m not debugging -- where should I start? Any other advice would be appreciated. (I&amp;#39;m still stuck with not having the TWI pins wiggle.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/612?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 13:28:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:336df34a-f54b-40fc-be07-e02a7f04c0a5</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Are you debugging while doing this?
Have you ensured that the device has not crashed or similar?&lt;/p&gt;
&lt;p&gt;Can you attach your source code + keil uvproj files so I can have a look?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/611?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 13:20:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4452f8d7-537f-42bf-8385-94061f204e66</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;By the way, I&amp;#39;m using the Revision 1.0 of the nRF51822 Evaluation Kit if that makes any difference.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/614?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 13:20:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71f1f50f-6e72-4462-9191-b2f81a500073</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;By the way, I&amp;#39;m using the Revision 1.0 of the nRF51822 Evaluation Kit if that makes any difference.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/610?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 13:01:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ec73256-86b1-48de-beac-2591f6c27d7d</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;static uint8_t m_device_address;
const uint8_t blah = 0x17;
m_device_address = 0x00 + (uint8_t)(0x39 [left shift] 1);&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for (;;)
{
  twi_master_transfer(m_device_address, (uint8_t*)&amp;amp;blah, 1, TWI_DONT_ISSUE_STOP);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/616?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 13:01:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7375739d-cd63-456c-8062-25375464761e</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;static uint8_t m_device_address;
const uint8_t blah = 0x17;
m_device_address = 0x00 + (uint8_t)(0x39 [left shift] 1);&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for (;;)
{
  twi_master_transfer(m_device_address, (uint8_t*)&amp;amp;blah, 1, TWI_DONT_ISSUE_STOP);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/609?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 13:00:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af6c62c5-4b70-4598-ba8d-ffc149c09c8b</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;Cut my previous comment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint8_t m_device_address;
const uint8_t blah = 0x17;
m_device_address = 0x00 + (uint8_t)(0x39 
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/615?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 13:00:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6718a4a8-185f-4a0a-87f4-725726191c35</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;Cut my previous comment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint8_t m_device_address;
const uint8_t blah = 0x17;
m_device_address = 0x00 + (uint8_t)(0x39 
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/608?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 12:59:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:157f42b2-46b9-46ec-843b-b76b9591cd24</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;Thanks! In the meantime, through that example I managed to get the pins defined -- those commands are done for me in the twi_master_init routine. I do see a logic high on both pin 24 and 25 (which is good!) but no toggling (looking at it with a scope) on them when I try to run the following in main():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint8_t m_device_address;
const uint8_t blah = 0x17;
m_device_address = 0x00 + (uint8_t)(0x39 
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/617?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 12:59:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a25f24e-76dc-467b-95af-6496b4c50f84</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;Thanks! In the meantime, through that example I managed to get the pins defined -- those commands are done for me in the twi_master_init routine. I do see a logic high on both pin 24 and 25 (which is good!) but no toggling (looking at it with a scope) on them when I try to run the following in main():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint8_t m_device_address;
const uint8_t blah = 0x17;
m_device_address = 0x00 + (uint8_t)(0x39 
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assigning a functional block to a GPIO</title><link>https://devzone.nordicsemi.com/thread/607?ContentTypeID=1</link><pubDate>Mon, 15 Jul 2013 12:46:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8d7a4b1-6246-4e81-aff9-7ffd86fd1b9b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Take a look at this example in the SDK:
C:\Nordic Semiconductor\nRF51 SDK_v4.3.0.27417\Nordic\nrf51822\Board\nrf6310\twi_sw_master_example&lt;/p&gt;
&lt;p&gt;The pin definition is shown in file &amp;quot;twi_master_config.h&amp;quot;.
This example uses a bit banged TWI, but if you switch that file with &amp;quot;twi_hw_master.c&amp;quot; instead, then you use the HW peripheral instead.&lt;/p&gt;
&lt;p&gt;The pin selection is done on these two lines:
NRF_TWI1-&amp;gt;PSELSCL = TWI_MASTER_CONFIG_CLOCK_PIN_NUMBER;
NRF_TWI1-&amp;gt;PSELSDA = TWI_MASTER_CONFIG_DATA_PIN_NUMBER;&lt;/p&gt;
&lt;p&gt;The defines are basically a GPIO number (between 0 - 30).
These two GPIOs will then be controlled by the TWI HW module until you disable the TWI.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>