RTOS & i2c

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi all,

we are using a BCM20737S on a custom PCB, and have another question left:

From the comments in the forum, I assume the BCM20737S is using ThreadX as RTOS (please correct me if I am wrong) and that the custom code is only called from the RTOS when needed (on startup, on pairing, on a timer event, on an interrupt etc...).  Most of our tasks involve I2C communication and are very short and not sensitive to errors, so we never had problems. But if we would like to do some longer and timing-sensitive communication via I2C which takes around 10 seconds, is there a way to ensure the current function is not interrupted and the thread is not suspended during execution?

(or are the I2C functions like cfa_bsc_OpExtended already giving a warranty that they are not interrupted during communication? An interrupt outside of the I2C transaction itself is probably easy to handle and likely very short).

Thanks for any answer or thoughts.

0 Likes
1 Solution
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Any operation that attempts to hold the CPU longer than 2 seconds will trigger the watchdog and reboot the system. Disabling the watchdog, while possible, is not recommended, will produce unpredictable behavior, and possibly seize up the system.

Your best bet will be breaking up your i2c calls into chunks and allowing the CPU to carry out other tasks in the between calls. 

Jacob

View solution in original post

4 Replies
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Any operation that attempts to hold the CPU longer than 2 seconds will trigger the watchdog and reboot the system. Disabling the watchdog, while possible, is not recommended, will produce unpredictable behavior, and possibly seize up the system.

Your best bet will be breaking up your i2c calls into chunks and allowing the CPU to carry out other tasks in the between calls. 

Jacob

Anonymous
Not applicable

Does this mean, that a call to a user function is never interrupted or suspended, unless it is hitting the 2 second limit?

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Individual i2c function calls are blocking operations. An individual i2c sequence will never be interrupted.

Additionally, the user-level thread will be allowed to run until that 2-seconds is up. Whether the RTOS is running some operations concurrently, I can't yet speak on, but it's definitely not stopping the user thread.

Jacob

JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

To add to my earlier post, it turns out that the user thread will actually be interrupted by the BLE hardware for periods on the order of 300us. Although an individual i2c op won't be interrupted, you'll be interrupted in between i2c calls despite kicking the watchdog.

Again, I must warn you against holding the user thread. If in BLE connection, this will likely be detrimental to the system.

Jacob