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

interrupt based i2c with softdevice

Hello,

I am using SDK 9.0 and softdevice 8.0 and testing on Evaluation board. I referred the i2c example driver suggested by Torbjorn in this link

I wrote a simple driver for eeprom and succeeded without the softdevice. But when I integrate with the softdevice, data is neither writing nor reading from eeprom. I am not getting i2c interrupts.

Can anyone help me procedure for i2c driver with softdevice?

Update: It is working when I commented the sd_nvic_SetPriority(SPI0_TWI0_IRQn, 1); and enabled using NVIC. I am using template application workspace and integrated i2c driver. But now BT is not advertising. The voltage on the board is 3.3V. Can anyone help me regarding drivers with BT stack?

Regards, Sowmya

  • Hello I re-checked and still I2C is not working with softdevice. Anyone can help to fix this?

  • The issue is fixed. We have to first initialise softdevice then initialise I2C. One more question is , is it mandatory to use PPI or soft device calls in i2c?

    My application is running without PPI or softdevice calls. I am using NVIC to enable interrupts.

  • Hi. Sorry for the late response. Torbjørn's example is based on an old TWI driver. The use of PPI channels is a legacy from revision 2 of the nRF51 which had a product anomaly causing the TWI to malfunction (the anomaly is documented in PAN V2.3). The workaround was to use PPI channels. To make it even more complicated the TWI and softdevice would sometimes fight over the same PPI channels, and that is why you see specialized softdevice calls in Torbjørn's TWI driver to handle proper delegation of PPI channels.

    Nowadays, however, if you use the latest 3rd revision nRF51, the PAN is fixed and you don't need to use the PPI channels at all. I realize it might be a little late to say now, but in SDK 9 there is a brand new TWI driver and I would highly recommend that you use this driver instead of the old one found in your example.

  • Hi, I tested the eeprom using the i2c driver provided with sdk. But I wanted the interrupt based and not to use state machine based which is using in twi driver. So I wrote my own driver and interrupt based and it is working without PPI or softdevice calls. Thank you for the reply regarding PPI usage in twi driver.

  • The TWI driver in SDK 9.0.0 can actually be used in both blocking and interrupt driven mode. Just pass an event handler to nrf_drv_twi_init(p_instance, p_config , event_handler);. However, I'm sure you can make a more efficient, interrupt driven TWI driver yourself.

Related