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

Parents
  • Attached are the latest waveforms and revised code showing port initialization. I found a wiring error to the sensor (no power) but still is not working. Apparently the TX is not completing because it always exits the following command in twi_master_write() with timeout = 0. Five CLK's are issued but no SDA.

    while(NRF_TWI1->EVENTS_TXDSENT == 0 && (--timeout)); // HANGING HERE (TIMEOUT ALWAYS 0)

    SDA-SCL 4.jpg

    SDA-SCL 5.jpg

    twi.txt

Reply
  • Attached are the latest waveforms and revised code showing port initialization. I found a wiring error to the sensor (no power) but still is not working. Apparently the TX is not completing because it always exits the following command in twi_master_write() with timeout = 0. Five CLK's are issued but no SDA.

    while(NRF_TWI1->EVENTS_TXDSENT == 0 && (--timeout)); // HANGING HERE (TIMEOUT ALWAYS 0)

    SDA-SCL 4.jpg

    SDA-SCL 5.jpg

    twi.txt

Children
  • 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