<?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 I2C problem ( ssd1306 display )</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32911/twi-i2c-problem-ssd1306-display</link><description>Hello, 
 I have a problem through which unfortunately I&amp;#39;m not able to come across alone. I&amp;#39;m using nRF52832 with softdevice and UART central example from SDK14.2 (..\examples\ble_central\ble_app_uart_c\pca10040\s132\arm5_no_packs). Right now I&amp;#39;m trying</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Apr 2018 15:33:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32911/twi-i2c-problem-ssd1306-display" /><item><title>RE: TWI I2C problem ( ssd1306 display )</title><link>https://devzone.nordicsemi.com/thread/127485?ContentTypeID=1</link><pubDate>Mon, 09 Apr 2018 15:33:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b20c5d8-9d13-410d-af8f-18fc98f070e5</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Without a 100ms delay you would like have problems with nrf_drv_twi_tx() be called multiple times in the while() loop,&amp;nbsp;another transaction&amp;nbsp;can be buffered while the first is executing. Also make sure that all variables are alive in the scope, so you don&amp;#39;t exit&amp;nbsp;ssd1306_command() before&amp;nbsp;nrf_drv_twi_tx() is completed, which may be the case here since you are potentially calling nrf_drv_twi_tx() multiple times.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI I2C problem ( ssd1306 display )</title><link>https://devzone.nordicsemi.com/thread/127204?ContentTypeID=1</link><pubDate>Fri, 06 Apr 2018 11:54:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4646d494-37cf-43e4-8f8d-f754365bcd2b</guid><dc:creator>Pawel Trznadel</dc:creator><description>&lt;p&gt;I think that I should be more specific about ssd1306_begin() function which I&amp;#39;m use in my project. The function looks like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void ssd1306_begin(uint8_t vccstate, uint8_t i2caddr, bool reset)
{
    _vccstate = vccstate;
    _i2caddr = i2caddr;
    UNUSED_VARIABLE(_i2caddr);

    _width = WIDTH = SSD1306_LCDWIDTH;
    _height = HEIGHT = SSD1306_LCDHEIGHT;

    cursor_y  = cursor_x    = 0;
    textsize  = 1;
    textcolor = textbgcolor = 0xFFFF;
    wrap      = true;
    _cp437    = false;

    rotation  = 0;
		
    // Init sequence for 128x32 OLED module
    ssd1306_command(SSD1306_DISPLAYOFF);                    // 0xAE
    ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV);            // 0xD5
    ssd1306_command(0x80);                                  // the suggested ratio 0x80

    ssd1306_command(SSD1306_SETMULTIPLEX);                  // 0xA8
    ssd1306_command(0x1F);
    ssd1306_command(SSD1306_SETDISPLAYOFFSET);              // 0xD3
    ssd1306_command(0x00);                                   // no offset
    ssd1306_command(SSD1306_SETSTARTLINE | 0x0);            // line #0
    ssd1306_command(SSD1306_CHARGEPUMP);                    // 0x8D
    if (vccstate == SSD1306_EXTERNALVCC) {
        ssd1306_command(0x10);
    }
    else {
        ssd1306_command(0x14);
    }
    ssd1306_command(SSD1306_MEMORYMODE);                    // 0x20
    ssd1306_command(0x0);                                  // 0x0 act like ks0108
    ssd1306_command(SSD1306_SEGREMAP | 0x1);
    ssd1306_command(SSD1306_COMSCANDEC);
    ssd1306_command(SSD1306_SETCOMPINS);                    // 0xDA
    ssd1306_command(0x02);
    ssd1306_command(SSD1306_SETCONTRAST);                   // 0x81
    ssd1306_command(0x8F);
    ssd1306_command(SSD1306_SETPRECHARGE);                  // 0xd9
    if (vccstate == SSD1306_EXTERNALVCC) {
        ssd1306_command(0x22);
    }
    else {
        ssd1306_command(0xF1);
    }
    ssd1306_command(SSD1306_SETVCOMDETECT);                 // 0xDB
    ssd1306_command(0x40);
    ssd1306_command(SSD1306_DISPLAYALLON_RESUME);           // 0xA4
    ssd1306_command(SSD1306_NORMALDISPLAY);                 // 0xA6
    ssd1306_command(SSD1306_DISPLAYON);//--turn on oled panel
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As you can see there is more then one ssd1306_command() function about which I&amp;#39;ve mentioned above.&lt;/p&gt;
&lt;p&gt;Right now I&amp;#39;ve changed&amp;nbsp;&lt;span&gt;ssd1306_command() function to be able to printf error code. I put here also nrf_delay_ms(100) because otherwise APP_ERROR_CHECK(ret) has reset my app befor error was printed:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;void ssd1306_command(uint8_t c)
{
        ret_code_t ret;
        uint8_t dta_send[] = {0x00, c};
				bool no_stop = false;
				
				m_xfer_done = false;
				while(!m_xfer_done){
					ret = nrf_drv_twi_tx(&amp;amp;m_twi_master, _i2caddr, dta_send, sizeof(dta_send), no_stop);
					printf(&amp;quot;error code:0x%x.\r\n&amp;quot;, ret);
					nrf_delay_ms(100);
					APP_ERROR_CHECK(ret);
				}
        UNUSED_VARIABLE(ret);
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Reason why I write about this is fact that when i call ssd1306_command() only once in ssd1306_begin() function, returned error code from nrf_drv_twi_tx() is 0x00, which means NRF_SUCCESS. Unfortunately every next call of ssd1306_command() (which include nrf_drv_twi_tx() ) cause 0x11 error code - NRF_ERROR_INVALID_ADDR.&lt;br /&gt;Has anyone idea where is the problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI I2C problem ( ssd1306 display )</title><link>https://devzone.nordicsemi.com/thread/127099?ContentTypeID=1</link><pubDate>Thu, 05 Apr 2018 15:07:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdd9505c-af91-4f43-9eed-cc042bf3e7e5</guid><dc:creator>Pawel Trznadel</dc:creator><description>&lt;p&gt;Unfortunately removal of&amp;nbsp;&lt;span&gt;hard coded values&amp;nbsp;&lt;/span&gt;didn&amp;#39;t help &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt;&lt;br /&gt;In my code only const argument in nrf_drv_twi_tx() function is TWI instance&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static const nrf_drv_twi_t m_twi_master = NRF_DRV_TWI_INSTANCE(0);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI I2C problem ( ssd1306 display )</title><link>https://devzone.nordicsemi.com/thread/127064?ContentTypeID=1</link><pubDate>Thu, 05 Apr 2018 13:37:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d042c2a-f133-40ee-adb3-efb5cf918d58</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Typically if for instance any of the parameters are of &amp;#39;const&amp;#39; type they may be placed in flash, not RAM. Also hard coded values, like the parameter value &amp;#39;2&amp;#39; may be stored in flash here. This will cause problem, so instead use a variable length = 2, and then use length variable as input parameter.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI I2C problem ( ssd1306 display )</title><link>https://devzone.nordicsemi.com/thread/126986?ContentTypeID=1</link><pubDate>Thu, 05 Apr 2018 09:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5658ebf1-49cd-4113-bf15-2734697ae45e</guid><dc:creator>Pawel Trznadel</dc:creator><description>&lt;p&gt;I&amp;#39;m afraid I&amp;#39;m not able to give an answer for your question. Could you specified when exactly this arguments will be not in RAM?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI I2C problem ( ssd1306 display )</title><link>https://devzone.nordicsemi.com/thread/126979?ContentTypeID=1</link><pubDate>Thu, 05 Apr 2018 08:33:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f809fe2e-3412-432b-bb8b-38d04a8b1a27</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Error code 11 (=NRF_ERROR_INVALID_ADDR) from nrf_drv_twi_tx() means &amp;quot;If the EasyDMA is used and memory adress in not in RAM.&amp;quot; Are you sure all parameters (pointers, values, data and addresses) here is in RAM, and not flash when calling&amp;nbsp;nrf_drv_twi_tx()?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI I2C problem ( ssd1306 display )</title><link>https://devzone.nordicsemi.com/thread/126930?ContentTypeID=1</link><pubDate>Wed, 04 Apr 2018 20:32:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:719ef603-e95a-47b4-9462-a66451a5ad79</guid><dc:creator>Pawel Trznadel</dc:creator><description>&lt;p&gt;Yes I&amp;#39;ve tried twi_scanner it returns correct i2c address as shown below:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: TWI scanner.
&amp;lt;info&amp;gt; app: TWI device detected at address 0x3C.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately I don&amp;#39;t have&amp;nbsp;&lt;span&gt;logic analyzer to monitor the SCL and SDA lines.&lt;br /&gt;&lt;br /&gt;It seems that I&amp;#39;m not receiving NRF_DRV_TWI_EVT_ADDRESS_NACK or&amp;nbsp;NRF_DRV_TWI_EVT_DATA_NACK events either.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ve just printf error code returned from&amp;nbsp;nrf_drv_twi_tx() function, and it&amp;nbsp;is 0x11, but unfortunately I&amp;#39;ve no idea what does it mean :( Have you any idea which of the error from this list match with my error number?&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt; * @retval NRF_SUCCESS                  If the procedure was successful.
 * @retval NRF_ERROR_BUSY               If the driver is not ready for a new transfer.
 * @retval NRF_ERROR_INTERNAL           If an error was detected by hardware.
 * @retval NRF_ERROR_INVALID_ADDR       If the EasyDMA is used and memory adress in not in RAM.
 * @retval NRF_ERROR_DRV_TWI_ERR_ANACK  If NACK received after sending the address in polling mode.
 * @retval NRF_ERROR_DRV_TWI_ERR_DNACK  If NACK received after sending a data byte in polling mode.&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI I2C problem ( ssd1306 display )</title><link>https://devzone.nordicsemi.com/thread/126766?ContentTypeID=1</link><pubDate>Wed, 04 Apr 2018 08:29:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:842b159e-a55c-414a-9e93-478bbce3a350</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you first tried:&amp;nbsp;\nRF5_SDK_14.2.0_17b948a\examples\peripheral\twi_scanner?&lt;/p&gt;
&lt;p&gt;Do you have a logic analyzer plot showing the SCL and SDA lines?&lt;/p&gt;
&lt;p&gt;Do you have other events such as&amp;nbsp;NRF_DRV_TWI_EVT_ADDRESS_NACK or&amp;nbsp;NRF_DRV_TWI_EVT_DATA_NACK instead of&amp;nbsp;NRF_DRV_TWI_EVT_DONE?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>