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

Parents
  • Hi,

    I suspect, that there is an issue with the pca10036 board or chip.

    I2C / TWI is not working, if I use the standard settings from nrf_drv_config.h.

    define TWI1_CONFIG_FREQUENCY    NRF_TWI_FREQ_100K
    #define TWI1_CONFIG_SCL          0
    #define TWI1_CONFIG_SDA          1
    #define TWI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
    

    With the default pins 0 and 1, I never get any signal.

    Therefore I tried various pin combinations:

           SCL  SCA
    pin:   0      1    does not work
           1      21      "
           21     5       "
           3      4       "
           5      6    works
           6      7    works
    

    So, for me the default settings are not usable, and even the working pin combinations I have to find out individually either by a program routine or with a logic analyzer. My toolchain is PCA10036, Keil uVision 5.x, SDK 0.9.2.

    Hopefully, this information helps somebody to save precious time. Thank you all, who commented on my question, which helped to solve the problem. Your Johannes

Reply
  • Hi,

    I suspect, that there is an issue with the pca10036 board or chip.

    I2C / TWI is not working, if I use the standard settings from nrf_drv_config.h.

    define TWI1_CONFIG_FREQUENCY    NRF_TWI_FREQ_100K
    #define TWI1_CONFIG_SCL          0
    #define TWI1_CONFIG_SDA          1
    #define TWI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
    

    With the default pins 0 and 1, I never get any signal.

    Therefore I tried various pin combinations:

           SCL  SCA
    pin:   0      1    does not work
           1      21      "
           21     5       "
           3      4       "
           5      6    works
           6      7    works
    

    So, for me the default settings are not usable, and even the working pin combinations I have to find out individually either by a program routine or with a logic analyzer. My toolchain is PCA10036, Keil uVision 5.x, SDK 0.9.2.

    Hopefully, this information helps somebody to save precious time. Thank you all, who commented on my question, which helped to solve the problem. Your Johannes

Children
Related