<?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>SSD1306 TWI SDK 15.2.0 Troubles</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63413/ssd1306-twi-sdk-15-2-0-troubles</link><description>Hi Nordic folks! 
 
 I&amp;#39;m in troubles with a Nordic nRF52 DK and a SSD1306 Display. I&amp;#39;m not able to print anything in the oled screen, I don&amp;#39;t really sure if it the problem it&amp;#39;s in the SSD1306 code functions, or it&amp;#39;s in the TWI library. I&amp;#39;m using the SDK</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 09 Jul 2020 09:24:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63413/ssd1306-twi-sdk-15-2-0-troubles" /><item><title>RE: SSD1306 TWI SDK 15.2.0 Troubles</title><link>https://devzone.nordicsemi.com/thread/259124?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2020 09:24:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:656e1000-4c27-4d23-99b8-fe9402e3ee67</guid><dc:creator>decastro_25</dc:creator><description>&lt;p&gt;Hi folks!!&lt;/p&gt;
&lt;p&gt;Finally, I achieve that the SSD1206 Oled works!! The problem was, as you suggest, in the buffer limitation.&lt;/p&gt;
&lt;p&gt;As the SSD1306 is 128x32, the number of bytes that you have to send is about 514 bytes. So, you have to distribute it in 3 TWI transmissions. And that&amp;#39;s all it finally works.&lt;/p&gt;
&lt;p&gt;I leave you here a video with the results.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/IMG_5F00_5136.MOV"&gt;devzone.nordicsemi.com/.../IMG_5F00_5136.MOV&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And also the code, for if it could help someone else.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_drv_twi.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

 //https://www.reddit.com/r/embedded/comments/9w9gm7/nrf52832_with_mcp4725/
  static uint8_t Logo [SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = {
  // &amp;#39;Logo, 32x32px
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0xff, 0xff, 0x00, 
0x01, 0xff, 0xff, 0x80, 0x03, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xf0, 
0x1f, 0xff, 0xff, 0xf8, 0x1f, 0xbb, 0xb9, 0xf8, 0x3f, 0xb9, 0xbd, 0xfc, 0x3f, 0xb9, 0xb9, 0xfc, 
0x3f, 0xbb, 0xbf, 0xfc, 0x7f, 0xff, 0xff, 0xfc, 0x7e, 0x03, 0xc0, 0xfe, 0x7e, 0x79, 0x9e, 0x7e, 
0x7e, 0xfe, 0xbf, 0x3e, 0x7e, 0xfe, 0xbf, 0x7e, 0x7e, 0xfe, 0x3f, 0xfe, 0x7e, 0xfe, 0x3f, 0xfc, 
0x3e, 0xfe, 0x3f, 0xfc, 0x3e, 0xfe, 0x3f, 0xfc, 0x3e, 0xfe, 0xbf, 0x38, 0x1e, 0xfc, 0xbf, 0x38, 
0x1e, 0x71, 0x8e, 0x70, 0x0e, 0x03, 0xc0, 0xe0, 0x07, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0x80, 
0x01, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xfc, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00
};
static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
    0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x80, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
    0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0xFF,
};

static volatile bool use_i2c = true;
static uint8_t _i2caddr, _vccstate;
static uint32_t _dc, _rs, _cs;
static int16_t _width, _height, WIDTH, HEIGHT, cursor_x, cursor_y;
static uint8_t textsize, rotation;
static uint16_t textcolor, textbgcolor;
bool wrap,   // If set, &amp;#39;wrap&amp;#39; text at right edge of display
     _cp437; // If set, use correct CP437 charset (default is off)

#define ssd1306_swap(a, b) { int16_t t = a; a = b; b = t; }
int16_t ssd1306_width(void)
{
    return _width;
}

int16_t ssd1306_height(void)
{
    return _height;
}

void ssd1306_draw_pixel(int16_t x, int16_t y, uint16_t color)
{
   // if ((x &amp;lt; 0) || (x &amp;gt;= ssd1306_width()) || (y &amp;lt; 0) || (y &amp;gt;= ssd1306_height()))
   //      return;

    // check rotation, move pixel around if necessary

    switch (rotation) {
    case 1:
        ssd1306_swap(x, y);
        x = WIDTH - x - 1;
        break;
    case 2:
        x = WIDTH - x - 1;
        y = HEIGHT - y - 1;
        break;
    case 3:
        ssd1306_swap(x, y);
        y = HEIGHT - y - 1;
        break;
    }

    // x is which column
    switch (color) {
    case WHITE:
        buffer[x + (y / 8)*SSD1306_LCDWIDTH] |=  (1 &amp;lt;&amp;lt; (y &amp;amp; 7));
        break;
    case BLACK:
        buffer[x + (y / 8)*SSD1306_LCDWIDTH] &amp;amp;= ~(1 &amp;lt;&amp;lt; (y &amp;amp; 7));
        break;
    case INVERSE:
        buffer[x + (y / 8)*SSD1306_LCDWIDTH] ^=  (1 &amp;lt;&amp;lt; (y &amp;amp; 7));
        break;

    }
}
void ssd1306_cleardisplay(void){
  for(int i = 0; i &amp;lt; (SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8); i++){
      buffer[i] = 0x00;
    }
}
/**
 * @brief Function for main application entry.
 */
//------------------------------------------//

void twi_write(uint8_t address, uint8_t data){
  uint8_t tx_buf[2];

  tx_buf[0] = 0x3C;
  tx_buf[1] = data;


  NRF_TWIM0-&amp;gt;SHORTS = TWIM_SHORTS_LASTTX_STOP_Enabled &amp;lt;&amp;lt;TWIM_SHORTS_LASTTX_STOP_Pos;

  NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf);
  NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf[0];

  NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
  NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
  while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
  while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
  nrf_delay_us(100);
  while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

}

void twi_owner_init(uint32_t address){
    NRF_GPIO-&amp;gt;PIN_CNF[2] |= (GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);
    NRF_GPIO-&amp;gt;OUTSET |= (1&amp;lt;&amp;lt;2);
    NRF_GPIO-&amp;gt;PIN_CNF[3] |= (GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);
    NRF_GPIO-&amp;gt;OUTSET |= (1&amp;lt;&amp;lt;3);

    NRF_GPIO-&amp;gt;PIN_CNF[26] |= (GPIO_PIN_CNF_PULL_Pullup &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos ) | ( GPIO_PIN_CNF_DIR_Input &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos ) | (GPIO_PIN_CNF_DRIVE_S0D1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos); // 3 PULL_UP | 0 DIR | 8 Drive sense
    NRF_GPIO-&amp;gt;PIN_CNF[27] |= (GPIO_PIN_CNF_PULL_Pullup &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos ) | ( GPIO_PIN_CNF_DIR_Input &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos ) | (GPIO_PIN_CNF_DRIVE_S0D1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos); // 3 PULL_UP | 0 DIR | 1 INPUT Buffer | 8 Drive sense

    NRF_TWIM0-&amp;gt;ENABLE = TWIM_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; TWIM_ENABLE_ENABLE_Pos; //Turn off TWIM0

    NRF_TWIM0-&amp;gt;PSEL.SCL = 0x1A; //SCL Pin
    NRF_TWIM0-&amp;gt;PSEL.SDA = 0x1B; //SDA Pin

    NRF_TWIM0-&amp;gt;ADDRESS = address; //Slave device address
    NRF_TWIM0-&amp;gt;FREQUENCY = 0x01980000; //100kHz TWI frecuency

    NRF_TWIM0-&amp;gt;ENABLE = TWIM_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; TWIM_ENABLE_ENABLE_Pos;
}
int main(void)
{

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();
    NRF_GPIO-&amp;gt;PIN_CNF[18] |= (GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);
    NRF_GPIO-&amp;gt;OUTCLR |= (1&amp;lt;&amp;lt;18);

    NRF_LOG_INFO(&amp;quot;TWI scanner started.&amp;quot;);
    NRF_LOG_FLUSH();

    twi_owner_init(0x3C);
    
    NRF_TWIM0-&amp;gt;SHORTS = TWIM_SHORTS_LASTTX_STOP_Enabled &amp;lt;&amp;lt;TWIM_SHORTS_LASTTX_STOP_Pos;

    NRF_LOG_INFO(&amp;quot;TWI init\n&amp;quot;);
    NRF_LOG_FLUSH();

    uint8_t tx_buf[]={0x00,0xAE,0xD5,0x80,0xA8};


    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf1[]={0x00,0x1F};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf1);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf1[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf2[]={0x00,0xD3,0x00,0x40,0x8D};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf2);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf2[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf3[]={0x00,0x14};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf3);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf3[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf4[]={0x00,0x20,0x00,0xA1,0xC8};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf4);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf4[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf5[]={0x00,0xDA,0x02,0x81,0x8F};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf5);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf5[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf6[]={0x00,0xD9};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf6);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf6[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};
    
    uint8_t tx_buf7[]={0x00,0xF1};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf7);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf7[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf8[]={0x00,0xD8,0x40,0xA4,0xA6,0x2E,0xAF};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf8);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf8[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    nrf_delay_ms(2000);

    ssd1306_cleardisplay();

    for(int i = 0; i &amp;lt; 127; i++) ssd1306_draw_pixel(i,25,WHITE);
        for(int i = 0; i &amp;lt; 127; i++) ssd1306_draw_pixel(i,17,WHITE);
            for(int i = 0; i &amp;lt; 127; i++) ssd1306_draw_pixel(i,10,WHITE);


    uint8_t tx_buf9[]={0x00,0x22,0x00,0xFF,0x21,0x00};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf9);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf9[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf10[]={0x00,0x7F};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf10);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf10[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_us(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf11[255];

    tx_buf11[0]=0x40;

    for(int i = 1; i &amp;lt; 255; i++){
      tx_buf11[i] = buffer[i];
    }

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf11);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf11[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_ms(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf12[255];

    tx_buf12[0]=0x40;

    for(int i = 1; i &amp;lt; 255; i++){
      tx_buf12[i] = buffer[i+255];
    }

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf12);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf12[0];

    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_ms(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    uint8_t tx_buf13[]={0x40,0x00,0x00};

    NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf13);
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf13[0];

    NRF_LOG_INFO(&amp;quot;%d\n&amp;quot;,sizeof(tx_buf13));
    NRF_LOG_FLUSH();
    NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
    while(NRF_TWIM0-&amp;gt;EVENTS_LASTTX == 0){};
    nrf_delay_ms(100);
    while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

    while(1){
     __WFE();
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SSD1306 TWI SDK 15.2.0 Troubles</title><link>https://devzone.nordicsemi.com/thread/258579?ContentTypeID=1</link><pubDate>Mon, 06 Jul 2020 11:35:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4f15708-b9a7-4617-92bb-7ed9006725c7</guid><dc:creator>decastro_25</dc:creator><description>&lt;p&gt;Hi Jorgen,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m going to try with the Logic Analyzer the response with an Arduino device, and with the libraries too, and I&amp;#39;ll check the differents between frames.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll notice you.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Although, I&amp;#39;ve started to develop my own TWI function to test if the problems are in the SDK libs.&lt;/p&gt;
&lt;p&gt;I leave you here the code if you want or can try it with a logic analyzer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_drv_twi.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;



#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

/**
 * @brief Function for main application entry.
 */
//------------------------------------------//

void twi_write(uint8_t address, uint8_t data){
  uint8_t tx_buf[3];

  tx_buf[0] = address;
  tx_buf[1] = data;
  tx_buf[2] = 0xF0;

  NRF_TWIM0-&amp;gt;SHORTS = TWIM_SHORTS_LASTTX_STOP_Enabled &amp;lt;&amp;lt;TWIM_SHORTS_LASTTX_STOP_Pos;

  NRF_TWIM0-&amp;gt;TXD.MAXCNT = sizeof(tx_buf);
  NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;tx_buf[0];

  NRF_TWIM0-&amp;gt;EVENTS_STOPPED = 0;
  NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
  while(NRF_TWIM0-&amp;gt;EVENTS_TXSTARTED == 0){};
  nrf_delay_us(100);
  while (NRF_TWIM0-&amp;gt;EVENTS_STOPPED == 0){};

}

void twi_owner_init(uint32_t address){
    NRF_GPIO-&amp;gt;PIN_CNF[2] |= (GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos);
    NRF_GPIO-&amp;gt;OUTSET |= (1&amp;lt;&amp;lt;2);

    NRF_GPIO-&amp;gt;PIN_CNF[ARDUINO_SCL_PIN] |= (GPIO_PIN_CNF_PULL_Pullup &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos ) | ( GPIO_PIN_CNF_DIR_Input &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos ) | (GPIO_PIN_CNF_DRIVE_S0D1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos); // 3 PULL_UP | 0 DIR | 8 Drive sense
    NRF_GPIO-&amp;gt;PIN_CNF[ARDUINO_SDA_PIN] |= (GPIO_PIN_CNF_PULL_Pullup &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos ) | ( GPIO_PIN_CNF_DIR_Input &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos ) | (GPIO_PIN_CNF_DRIVE_S0D1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos); // 3 PULL_UP | 0 DIR | 1 INPUT Buffer | 8 Drive sense

    NRF_TWIM0-&amp;gt;ENABLE = TWIM_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; TWIM_ENABLE_ENABLE_Pos; //Turn off TWIM0

    NRF_TWIM0-&amp;gt;PSEL.SCL = 0x1A; //SCL Pin
    NRF_TWIM0-&amp;gt;PSEL.SDA = 0x1B; //SDA Pin

    NRF_TWIM0-&amp;gt;ADDRESS = address; //Slave device address
    NRF_TWIM0-&amp;gt;FREQUENCY = 0x01980000; //100kHz TWI frecuency

    NRF_TWIM0-&amp;gt;ENABLE = TWIM_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; TWIM_ENABLE_ENABLE_Pos;
}
int main(void)
{

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();
    
    NRF_LOG_INFO(&amp;quot;TWI scanner started.&amp;quot;);
    NRF_LOG_FLUSH();

    twi_owner_init(0x3C);
    
    NRF_LOG_INFO(&amp;quot;TWI init\n&amp;quot;);
    NRF_LOG_FLUSH();

    //Begin function
    twi_write(0x3C, 0xAE);
    nrf_delay_us(100);
    twi_write(0x3C, 0xD5);
    nrf_delay_us(100);
    twi_write(0x3C, 0x80);
    twi_write(0x3C, 0xA8);
    twi_write(0x3C, 0x1F);
    twi_write(0x3C, 0xD3);
    twi_write(0x3C, 0x0);
    twi_write(0x3C, 0x40|0x0);
    twi_write(0x3C, 0x8D);
    twi_write(0x3C, 0x14);
    twi_write(0x3C, 0x20);
    twi_write(0x3C, 0x0);
    twi_write(0x3C, 0xA0|0x1);
    twi_write(0x3C, 0xC8);
    twi_write(0x3C, 0xDA);
    twi_write(0x3C, 0x02);
    twi_write(0x3C, 0x81);
    twi_write(0x3C, 0x8F);
    twi_write(0x3C, 0xD9);
    twi_write(0x3C, 0xF1);
    twi_write(0x3C, 0xDB);
    twi_write(0x3C, 0xA4);
    twi_write(0x3C, 0xA6);
    twi_write(0x3C, 0xAF);
    NRF_LOG_INFO(&amp;quot;Begin funct\n&amp;quot;);
    NRF_LOG_FLUSH();
    //Display function
    twi_write(0x3C, 0x21);
    twi_write(0x3C, 0x0);
    twi_write(0x3C, 127);
    twi_write(0x3C, 0x22);
    twi_write(0x3C, 0x0);
    twi_write(0x3C, 0x3);
    twi_write(0x3C, 0x40);

    NRF_LOG_INFO(&amp;quot;Display funct\n&amp;quot;);
    NRF_LOG_FLUSH();

    NRF_LOG_INFO(&amp;quot;TWI end\n&amp;quot;);
    NRF_LOG_FLUSH();
    

    while(1){
     __WFE();
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SSD1306 TWI SDK 15.2.0 Troubles</title><link>https://devzone.nordicsemi.com/thread/258556?ContentTypeID=1</link><pubDate>Mon, 06 Jul 2020 09:47:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4287bcf-fc6a-4b2f-b27a-31a10c1d981b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Did you check the TWI bus with a logic analyzer to see if all commands are sent correctly to the display?&lt;/p&gt;
&lt;p&gt;Note that the nrf_drv_twi_tx/rx API has only 8bit length fields due to a limitation in supported EasyDMA size in nRF52832 chips. If you need to write more data than 255 bytes in one transfer you need to use the legacy TWI with nrfx_twi.c driver. Alternatively, you can split the data into multiple transfers if the slave supports this.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>