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

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

Reply
  • 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.

Children
No Data
Related