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
  • Don't use the twi driver to test, write the registers directly. Try both of the TWI masters, either in legacy TWI mode or the new TWIM mode, not that there's a lot of difference. Since TWI isn't mentioned as not working in the errata sheet, it's working, writing something direct to the hardware instances will tell you if you have a hardware issue on your board. But that doesn't really seem likely, if the rest of the chip is working, there's no reason both TWIs should just be failed.

    Just make sure you put the right thing in the ENABLE register - needs to be '5' to enable the TWI and disable the other peripherals at the same address.

    Should take no more than 20 lines of code to pump one byte out of the TWI master which you can capture on the analyser and show TWI is working.

    Once you've proved at least one of them works, you can look at why the code using the driver doesn't.

Reply
  • Don't use the twi driver to test, write the registers directly. Try both of the TWI masters, either in legacy TWI mode or the new TWIM mode, not that there's a lot of difference. Since TWI isn't mentioned as not working in the errata sheet, it's working, writing something direct to the hardware instances will tell you if you have a hardware issue on your board. But that doesn't really seem likely, if the rest of the chip is working, there's no reason both TWIs should just be failed.

    Just make sure you put the right thing in the ENABLE register - needs to be '5' to enable the TWI and disable the other peripherals at the same address.

    Should take no more than 20 lines of code to pump one byte out of the TWI master which you can capture on the analyser and show TWI is working.

    Once you've proved at least one of them works, you can look at why the code using the driver doesn't.

Children
No Data
Related