I have two peripheral devices on the same I2C port. One device is an OLED display and the other device is temperature sensor. Because I am using ThreadX (RTOS) to divide the time between the two devices, I have to make sure that the bus is locked to one device at a time. I learned that the framework is supposed to do automatically and makes the code much simpler than the lock/unlock method.
But, one a while, the first or second OLED i2c write call (after temperature sensor reading is done) will break and return with an error. How can I debug my code and fix this issue?
tx_event_flags_get(&g_system_event_flags, SENSOR_BUS_READY_FLAG, TX_AND, &event_flags, TX_WAIT_FOREVER); // I have this line in both device threads. // it is supposed to ensure when the bus is // available and clear to use.
PS: SSP 1.3.0, S5D9 IOT board
could you check if the problem can be solved by changing the r_riic priorities: Transmit Interrupt Priority and Transmit End Interrupt Priority. Please refer to the following document for details:SSP v1.3.0 Release Notes > section 9.7 r_riicSSP v1.3.2 Release Notes > section 9.7 r_riic
Please also look at the description of Issue ID: 9734 in the above resource which explains how to provide sufficient delay for the data transaction.
In reply to anper:
In reply to Mike:
I provided incorrect link in my previous post - it supposed to be SSP v1.3.2 Release Notes. I corrected it. I do have in mind that you are using SSP 1.3.0, however it is worth trying also the workarounds proposed in the above document. Please also review the:SSP v1.3.0 Release Notes > sections 9 and 10for possible issues with I2C.
Please try to use SSP 1.3.2, if you can, as it may solve some problems.
Another thing I noticed is that you use TX_AND option in the tx_event_flags_get() function call. Could you try using TX_AND_CLEAR option? This will cause the flags which match SENSOR_BUS_READY_FLAG to be cleared after being retrieved. For details please refer to:X-Ware Component Documents for Renesas Synergy > ThreadX User’s Manual: Software > Event Flags (p.80)X-Ware Component Documents for Renesas Synergy > ThreadX User’s Manual: Software > tx_event_flags_get (p.146)
it's good to hear that you managed to solve the problem.