This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

OLED SSD1306 with nRF52840 DK Not Working

Hi,

I am trying to interface OLED(SSD1306 driver) module/break-out with nRF52840 D.K, PCA10056 1.0.0 but it's showing some noise/dots/garbage.
Code: nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_uart
Merged: ssd1306 driver & enabled twi_sensor for i2c communication.
Softdevice: nRF5_SDK_15.2.0_9412b96\components\softdevice\s140


#define OLED_SCL NRF_GPIO_PIN_MAP(0,14)
#define OLED_SDA NRF_GPIO_PIN_MAP(0,13)


Code Snippet of twi:

/* TWI instance ID. */
#define TWI_INSTANCE_ID     		1

/* Indicates if operation on TWI has ended. */
static volatile bool m_xfer_done = false;

/* TWI instance. */
static const nrf_drv_twi_t m_twi_master = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);

void twi_init (uint32_t scl, uint32_t sda)
{
    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_m_config = {
       .scl                = scl,
       .sda                = sda,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&m_twi_master, &twi_m_config, NULL, NULL);
    APP_ERROR_CHECK(err_code);

    nrf_drv_twi_enable(&m_twi_master);
}

*
Rest is same as ssd1306_init(sda,scl)

I have tried following:

  1. Same OLED(SSD1306 driver) module/break-out works with nRF51422 D.K, PCA10028 using same ssd1306 drivers but twi_init() is like this which works properly:
    /**
     * @brief TWI master instance
     *
     * Instance of TWI master driver that would be used for communication with simulated
     * eeprom memory.
     */
    static const nrf_drv_twi_t m_twi_master = {
        .p_reg       = NRF_TWI0,
        .irq         = TWI0_IRQ,
        .instance_id = TWI0_INSTANCE_INDEX
    };
    
    
    void twi_evt_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
    {
    #if 0
        if (p_event->type == NRF_DRV_TWI_ERROR) {
            printf("E\r\n");
        }
    
        if (p_event->type == NRF_DRV_TWI_TX_DONE) {
            printf("T\r\n");
        }
    
        if (p_event->type == NRF_DRV_TWI_RX_DONE) {
            printf("R\r\n");
        }
    #endif
    }
    
    
    ret_code_t twi_master_init(uint32_t scl, uint32_t sda)
    {
        ret_code_t ret;
        const nrf_drv_twi_config_t config = {
            .scl                = scl,
            .sda                = sda,
            .frequency          = TWI0_CONFIG_FREQUENCY,
            .interrupt_priority = TWI0_CONFIG_IRQ_PRIORITY
        };
    
        do {
            ret = nrf_drv_twi_init(&m_twi_master, &config, /*twi_evt_handler*/ NULL,NULL);
            if (NRF_SUCCESS != ret) {
                break;
            }
            nrf_drv_twi_enable(&m_twi_master);
        }
        while (0);
        return ret;
    }
    


  2. Checked other devzone posts with same issues but didn't worked.
  3. Checked slave address of ssd1306.
  4. Checked i2c bus.

Check attached images & OLED module is powered via nRF52840D.K  VDD PIN. Also same was the case with nRF51422 D.K VDD PIN used to power OLED which worked. Please reply for possible solutions to debug this issue.


Regards

Vishal Aditya
Embedded Software Engineer

Parents Reply Children
No Data
Related