This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

TWI not working on nrf52832 dev board: NRF_DRV_TWI_ERROR

Hi,

I have a pretty hard time to get I2C/TWI running on my 52832 Dev-board (pca 10036). My problem is, that i do not get any physical I2C signal out of the board's pins. I tried nordic's TWI master/slave example from the SDK 0.9.2, shortened the relevant pins, with no success. Then I wrote a minimal TWI test programm. E.g.:

const nrf_drv_twi_t           p_twi_instance = NRF_DRV_TWI_INSTANCE(1);

ret_code = nrf_drv_twi_init(&p_twi_instance, &p_twi_config, twi_event_handler); // Initiate twi driver with instance and configuration values
APP_ERROR_CHECK(ret_code); // Check for errors in return value

nrf_drv_twi_enable(&p_twi_instance); // Enable the TWI instance

// Send dummy data on TWI buss on address 0x68
 ret_code = nrf_drv_twi_tx(&p_twi_instance, address, &dummy_data, 1, false);

and handle the twi event:

// TWI event handler. Processing TWI events originating from
// nrf_drv_twi_tx()

static void twi_event_handler(nrf_drv_twi_evt_t *evt){

   if(evt->type == NRF_DRV_TWI_ERROR)
   {
      /* Error 2 is
      * NRF_TWI_ERROR_ADDRESS_NACK = TWI_ERRORSRC_ANACK_Msk,
      * NACK received after sending the address.
      * as defined in nrf_twi.h
      * So I guess I don't get any response from my external device.
      */
   }

   if(evt->type == NRF_DRV_TWI_TX_DONE)
   {
      SEGGER_RTT_printf(0,"TWI event success ...\r\n");
   }
}

The TWI is initiated without any error and the program runs fine, but in the event handler I always get a NRF_DRV_TWI_ERROR, regardless of the TWI slaves.

Then i attached my Saleae Logic Analyzer into the TWI bus with 10K Ohm pull-up resistors to see, if there are any logic signals. But neither for SCL nor SCA pins was any signal detected.

Then I probed every pin on the 52832 Dev-Board with the logic analyzer, just to make sure I don't have misconfigured pins, but i could not get any signal on any pin.

Next I probed the logic analyzer with a 51822 board, and with this board I can see the SCL and SCA signals, so the logic analyzer is working correctly.

So, is TWI (nrf_drv_twi.c, etc.) working on a 52832 Dev-board?

Any idea, why I don't even get the TWI clock signal on the pin?

Is my board maybe physically damaged?

Any help is greatly appreciated! Yours Johannes

  • Hey Johannes, I don't have experience with 52832 Dev-board but I faced a lot of issues while setting up i2c for my custom board using 51822. I tried with the twi drivers by nrf and received a NACK just like you did. When I probed using Salae, I realized that a particular stop bit was missing which ended up disrupting the whole communication. After a lot of debugging, I ended up using the 'incubated' libraries in the twi_master folder (twi_hw_master.c and twi_master.h). Haven't faced any issues with that so far!

  • Hi Vandita, I also tried the drivers and files from the incubated folder, but also with no success. Therefore I suspect that either TWI is not working at all with nrf52, or my board is faulty. The strange thing is, that i get not any single signal, not even the clock signal, detected with the Saleae. Yours Johannes

  • Try a simpler test - write the registers directly to set the pins up and send out/read in some data. The Saleae will tell you if it does anything or not.

    What pins are you using? Did you pick pins which are assigned to something else like NFC? Try using different pins.

    I see no errata about a TWI not working - I did waste 2 hours trying to get SPI0 working before I found that .. it didn't, but TWI should.

  • Hi RK,

    I already tried different pins, e.g. 3,4,5,6,7,8, 20,21,30, each configured in the respective header file, erased the board and flashed it completely with the new compiled application. Meanwhile, I waste 3 days :-( If your are successful with TWI, please let me know. Yours Johannes

  • The combination of the nRF52832 and the SDK 9.0.0? Why don't you use nRF51 SDK 10.0.0 or nRF52 SDK 0.9.2? I'm using nRF52-DK with the nRF51 SDK 10.0.0 and TWI works well.

Related