Hello, i have a strange situation here with TWI module and i have no idea what is happening. I have read a lot of posts here on devzone and the code i am using is also found somewhere on this forum, however in none of the post i found the same behaviour which i am seeing. I have a temperature sensor which is driven via i2c, so for this i am trying to use TWI. Piece of code which i am using is atached in the picture below.
If i am letting the code to run, then i hit a break-point at line 283. After i let the code to run again, i hit a break-point at line 286. At line 285 i am sending data to sensor with ret_code = nrf_drv_twi_tx(&p_twi_instance, 0x40, &dummy_data, 1, false);
In this case, this is what i am seeing with oscilloscope on SCL and SDA lines:
If i remove a break-point at line 283 and allowing the code to run, i hit a break-point at line 286 and this is what i am seeing with oscilloscope in this case:
Also, this time i see in TWI1 events, that EVENTS_ERROR is set. Also, in TWI1_ERRORSRC register i have ANACK bit set. After this i have tried to do my own version of twi communication with sensor by modifying TWI1 module registers directly. However, that gives exactly the same results. Putting the break-point between sending data, and then running the code again - communication is seen. If allowing the code to run without any breakpoints, device gives NACK and communication fails.I don't understand what is causing this behaviour. Any help is appreciated. By the way, i am using SoftDevice S110_V8.
@ EDIT: After adding delay after TWI module initialization, and sending data. I don't understand however what is causing small voltage drop just few ms before starting communication?: delay.png