<?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>TWI communication issue with nRF52840 Dongle</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61151/twi-communication-issue-with-nrf52840-dongle</link><description>Dear Nordic Team, 
 We are working on connecting an I2C device to an nRF52840 Dongle . The code we are using is one we&amp;#39;ve been developing for a few weeks with an nRF52840 DK with which it works fine. As we&amp;#39;re making the transition to the dongle we&amp;#39;ve</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 08 May 2020 12:08:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61151/twi-communication-issue-with-nrf52840-dongle" /><item><title>RE: TWI communication issue with nRF52840 Dongle</title><link>https://devzone.nordicsemi.com/thread/248928?ContentTypeID=1</link><pubDate>Fri, 08 May 2020 12:08:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1244e066-5a0c-4f9e-99be-23181dfda286</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It seems that you&amp;#39;re using the NFC pins as TWI SCL/SDA pins (P0.09 and P0.10). You need the preprocessor define &amp;quot;CONFIG_NFCT_PINS_AS_GPIOS&amp;quot; set in order to use those as normal GPIOs, or use any other available GPIOs for this purpose. On development kits (nrf52-DK, nrf52840-DK, etc), you also need to move some zero-ohm resistors to route the signals to the pin header.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI communication issue with nRF52840 Dongle</title><link>https://devzone.nordicsemi.com/thread/248792?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 16:40:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:549bb949-d4bf-439e-a870-b4d908694eb0</guid><dc:creator>Gyuri</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void i2c_write( uint8_t address, uint8_t * data, int count ) {
    m_xfer_done = false;
    m_err_code = nrf_drv_twi_tx( &amp;amp;m_twi, address, data, count, false );
    if ( m_err_code != NRF_SUCCESS ) {
      NRF_LOG_DEBUG( &amp;quot;I2C WRITE ERROR: %d\r\n&amp;quot;, m_err_code );
    }
    while (m_xfer_done == false){
    blinkit();
    };
    APP_ERROR_CHECK( m_err_code );
}

/* Blocking reading call for I2C */
void i2c_read( uint8_t address, uint8_t * data, int count ) {
    m_xfer_done = false;
    m_err_code = nrf_drv_twi_rx( &amp;amp;m_twi, address, data, count );
    if ( m_err_code != NRF_SUCCESS ) {
    	NRF_LOG_DEBUG( &amp;quot;I2C READ ERROR: %d\r\n&amp;quot;, m_err_code );
        printf( &amp;quot;I2C READ ERROR: %d\r\n&amp;quot;, m_err_code );
    }
    while (m_xfer_done == false);
    APP_ERROR_CHECK( m_err_code );
}

/**
 * @brief TWI events handler.
 */
void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
{
    switch (p_event-&amp;gt;type)
    {
        case NRF_DRV_TWI_EVT_DONE:
            m_xfer_done = true;
            break;
        default:
            break;
    }
}

void twi_init(void){

    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_LSM6DS33_config = {
       .scl                = SCL_PIN,
       .sda                = SDA_PIN,
       .frequency          = NRF_DRV_TWI_FREQ_400K,
       .interrupt_priority = APP_IRQ_PRIORITY_LOW,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_LSM6DS33_config, twi_handler, NULL);
    APP_ERROR_CHECK(err_code);

    nrf_drv_twi_enable(&amp;amp;m_twi);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;TWI init and write&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifndef PCA10059_H
#define PCA10059_H

#ifdef __cplusplus
extern &amp;quot;C&amp;quot; {
#endif

#include &amp;quot;nrf_gpio.h&amp;quot;

// LED definitions for PCA10059
// Each LED color is considered a separate LED
#define LEDS_NUMBER    4

#define LED1_G         NRF_GPIO_PIN_MAP(0,6)
#define LED2_R         NRF_GPIO_PIN_MAP(0,8)
#define LED2_G         NRF_GPIO_PIN_MAP(1,9)
#define LED2_B         NRF_GPIO_PIN_MAP(0,12)

#define LED_1          LED1_G
#define LED_2          LED2_R
#define LED_3          LED2_G
#define LED_4          LED2_B

#define LEDS_ACTIVE_STATE 0

#define LEDS_LIST { LED_1, LED_2, LED_3, LED_4 }

#define LEDS_INV_MASK  LEDS_MASK

#define BSP_LED_0      LED_1
#define BSP_LED_1      LED_2
#define BSP_LED_2      LED_3
#define BSP_LED_3      LED_4

// There is only one button for the application
// as the second button is used for a RESET.
#define BUTTONS_NUMBER 1

#define BUTTON_1       NRF_GPIO_PIN_MAP(1,6)
#define BUTTON_PULL    NRF_GPIO_PIN_PULLUP

#define BUTTONS_ACTIVE_STATE 0

#define BUTTONS_LIST { BUTTON_1 }

#define BSP_BUTTON_0   BUTTON_1

#define BSP_SELF_PINRESET_PIN NRF_GPIO_PIN_MAP(0,19)

#define SDA_PIN       NRF_GPIO_PIN_MAP(0,9)
#define SCL_PIN       NRF_GPIO_PIN_MAP(0,10)

#define HWFC           true

#ifdef __cplusplus
}
#endif

#endif // PCA10059_H
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Pin define&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI communication issue with nRF52840 Dongle</title><link>https://devzone.nordicsemi.com/thread/248791?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 16:21:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e46c1d7a-b2de-4b2f-99b2-440a331d83de</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/6371._5F00_Insert-Code-_2D00_-Nordic-2.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>