Why did I2C communication failure cause 9160 to crash?

I used 9160 to develop a project for the customer. During the project test, sometimes the data line or clock line level of I2C was abnormal due to hardware reasons. I wonder why the firmware stayed in the thread of I2C communication and could not be returned, which led to the system crash?  I also had this problem with 52840, but it didn't cause the system to crash, because the I2C communication there would have a callback function telling me the result of the communication. If it didn't return, I could set timeout in the firmware and continue with the next step, but not with 9160.  It has been stuck in i2C_transfer and crashed. Why is this?  

Parents Reply Children
  • I'm sorry that I didn't express it clearly. I tracked it down in the code and found that something went wrong during transmission.  like this:

    I don't know why it need to waiting forever and didn't get any message from event_handler  :

  • Are you passing the correct parameter to k_sem_take_forever? I'm not sure if get_dev_data(dev)->completion_sync would return the address. 

  • Thanks for your reply.  I can confirm that the correct parameters have been passed in, and I2C can be used for communication even when the peripheral is normal. Only when the peripheral works abnormally, its SCL and SDA line level of I2C is abnormal (for example, the level is always high or low), which will cause 9160 to crash.  

  • Hi,

    I'm a bit confused. My understanding was that the I2C peripheral asserted during the reading process after initialization. . 

    duxinglang said:
    but the system crashes during the reading process, here is its location and execution code:

    I therefore asked exactly where in the code it stops during the reading process, and you pointed to the k_sem_take()

    duxinglang said:
    I tracked it down in the code and found that something went wrong during transmission. 

    But then you write:

    duxinglang said:
    can confirm that the correct parameters have been passed in, and I2C can be used for communication even when the peripheral is normal.

    I suggest that you connect the SDA and SCL line to a logic analyzer and see what is sent when the program asserts. You should check if the data that is sent is what you expected and if it is according to what is specified in the datasheet.

    regards

    Jared 

  • I used the logic analyzer to check the level changes of SDA and SCL. Yes, when this happens, there are some abnormalities in the peripherals, which leads to the high or low level of SDA or SCL. This is what I can expect, but my question is, even if the external causes I2C abnormalities, why does this abnormality cause the collapse of 9160? Can the 9160, as a host, not automatically return an error when it encounters an abnormal communication timeout, and then continue the following instructions? Why stay here all the time? I tested nrf52810 and found it wouldn't crash.

Related