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
  • Hi, 

    You have shared 4 images of your code, but I'm not sure which one that shows where it asserts. Can you debug the application and show the call stack when the program asserts? Is there any log messages that is outputted when the program asserts?

    regards

    Jared 

  • 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 

Related