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

TWI on nRF51822

I just entered a Case to Nordic with this same question but do not expect to get a response over the weekend so I am posting here. I made the assumption that the Nordic Cases and the Developer Zone are not related. If this is considered a double-post I apologize.

I used the RF6350_radio_configuration_example as a starting point for our TWI interface. The goal is for the nRF51822 to act a a Master and send commands to a Slave to read/write the Slave's RAM/EEPROM.

I am using the nRF51822 EK with our TWI Slave attached and uVision 4 and the TWI transmission are unsuccessful. When a command is issured there are two negative SDA pulses followed by continuous SCL pulses. (36 usec period = 27.8KHz). The Slave requires clock freuencies of 10KHz-100KHz. When the code reaches “if (timeout == 0)” in the twi_master_write() while loop timeout always equals 0 which may be why the transmissioin fails. Of course this may not be the only problem.

I am still plugging away on this but time is short so any suggestions will be appreciated.

twi.txt

  • Hi Tom

    Have you by any chance got the Softdevice loaded onto your device?

  • Hi Tom,

    It looks like you are relying on the pullup resistors in the nRF51822 for the TWI interface.

    I searched the nRF51822 data sheet and could find nothing about the actual pullup resistor value :( See Tielman's reply to my post, I should have been looking in the Product Spec, not the Reference Manual

    In my experience, these values tend to be any where from 10K to 200K in other products. When I design TWI (I2C) interfaces, I typically use 4.7K . If the pullup resistor is too high a resistance (which may be true in your case), then the rising edges on SDA and SCL can be too slow, and it may not rise to a valid logic high. You SDA_SDL_2.jpg picture certainly suggests this.

    If your devices have different power rails, such as 2.5 V for one device and 3.0 for the other, the pull up resistors should connect to the higher rail. This won't work if there is significant difference (2.5V and 5V), in which case you need a level shifter as well as the pullup resistors.

    Cheers, Philip

  • The product specification for the NRF51822 actually specifies the RPU (pull-up resistance) for the GPIO to be about 13k (page 48 of PS v1.3).

    Tom, I do agree with Philip though that 13k might not be enough for many devices and I also typically use 4.7k. I Still suggest that you try external pull-ups and see if you cant get your comms working. If it doesn't work, then we can dig further.

  • Is it just me, or does your clock waveform appear to be upside down? Are you sure there's no polarity issue?

    The waveform of the clock looks about right -- I'm not sure it's a pull-up issue personally, you would see more of a "saw tooth" waveform if you needed pull-ups IMHO. But I could be completely wrong, so give it a try with 4.7K (or anything you have between 1.5-10K).

    Also, is it possible you have a clocking issue? I haven't finished my first pot of coffee yet, but on first look I didn't think you were generating a 400KHz clock...

    Hopefully that might give you some other places to look :)

    -m

  • I notice that you initialize your twi master, but don't check to see if it was successful. Maybe just check that as well. I recently had a I2C device that caused the twi_master_init to fail if the device was not powered before the twi_master_init function was called. Probably not the issue, but still a good habit to check initialization before use.

Related