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

TWI Does not work

Hello, i am trying to develope a I2C  application. 

I am using the twi_sensor example of the SDK 12.3.0

I have configured my pins to SDA 14 and SCL 30 and i just want to send some data with the  nrf_drv_twi_tx funtion... but nothing happens. I am monitoring the gpio 14 and the gpio 30 with my osciloscope and i just see the 3.3v provided by the pull up resistor... nothing else... 

What i am doing wrong ?

Thank you so much in advance 

Best regards 

Parents Reply Children
  • The program will send one transfer, wait for a successful event, then do another.

    If the transfer is not successful, it will send one transaction and then hang forever. This is the reason why I asked if you could reset the device and capture the trace and see if you get any output on SCL/SDA pins. Regardless, this points towards a issue with addressing the i2c sensor. Please doublecheck that the i2c address is correct, and please verify that the i2c master sends anything on boot-up.

     

    Kind regards,

    Håkon

  • I have reduced the problem to the minimum now: 

    • I am using sdk12 3 twi_sensor example
    • I am using pca10028 board
    • I have installed a 2,5k pull up resistor from gpio07 to vcc
    • I have installed a 2,5k pull up resistor form gpio30 to vcc


    I have no sensor connected now. I load the example and i see absolutely nothing in the scope...

    I have reset the device but even with this i can not see anything... 



  • Here's my scope when triggering on SDA line:

    I used internal pullup in the GPIO. Since you use 2.5kOhm, you sink ~1 mA, which might require you to setup the GPIOs in high-drive mode (See NRF_GPIO->PIN_CNF[] register). You could try a bit of a weaker pull-resistor, but you should still see something on your oscilloscope just after reset.

     

    for testing purposes: You could also set m_xfer_done=true in function main.c::twi_handler(), regardless of event received. This will then send every ~0.5 second.

     

    Kind regards,

    Håkon

  • Ok, now i can see that setting  m_xfer_done to true the system sends a command each 0,8s more or less... What  m_xfer_done does? Does it is set to true when the master receive an ACK? Why if i force this variable to true it sends periodically a command? 

    In my real application i want to use this twi with: 

    Soft device (Timer 0) for BLE_UART
    Timer 1: interruption
    Timer 2: pwm 

    If i copy the twi code to my real app... it does not generate any command even if i force m_xfer_done to true. Is there any conflict with the resources i mention before? 

    Thanks a lot!

Related