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

faster TWI on nrf51822

I've been working on an interrupt driven I2C driver. I have the basic driver working, but I'm hoping to squeeze a bit more speed out of it.

I'm mostly doing fairly long transactions, ~10-100 bytes. For one device I do mostly writes and for the other I do mostly reads.

At 400khz a byte takes around 20us and there is a ~4us delay before next byte. The interrupt handler takes about 6us (timed using a gpio) and starts slightly before the falling edge of the the ack clock.

I might be able to shave the interrupt handler down a bit, but it is mostly reading/writing to EVENTS_*, reading from TXD and writing to RXD, there is very little other code in the middle of a transaction. I'm using BB_STOP and BB_SUSPEND shorts to save a PPI channel.

Most I2C devices will happily run faster, so I tried increasing the FREQUENCY register.

100khz is 0x01980000, 250 is 0x04000000, 400 is 0x06680000.

0x07800000 gave me a ~480khz clock some of the time, but other times the clock is more like 240khz with som 480khz clocks mixed in. 0x08000000 should be about ~500khz, but I see mostly a 250khz output.

The part I'm testing with doesn't seem to support clock stretching. I'd imagine what I'm seeing is some sort of weirdness with how the nrf51 synthesizes the I2C clock. Are there any frequency values that will result in a clock that is >400khz?

Any suggestions on how to speed up the TWI interface?

  • Hi Clem,

    I found this thread (and your 7/24/2014 post on a different thread) while searching for tips on interrupt-driven I2C for the nRF51822. I'm in the same situation--needing to implement a non-blocking I2C driver. But I'm just getting started.

    Would you be willing to share some of your solution code for interrupt driven I2C? As others have noted, it doesn't appear that Nordic has provided examples in the SDK. I'd be happy to return the favor if I resolve any of the issues you mentioned above. But for now I'm starting from scratch. ;-(

    Thanks for your contributions.

Related