I have seen examples that use either I2CMasterIntStatusEx or I2CMasterBusy in a tight while loop to wait for I2C transfer completion. What is the advantage of I2CMasterIntStatusEx if a tight loop is used in both cases?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I have seen examples that use either I2CMasterIntStatusEx or I2CMasterBusy in a tight while loop to wait for I2C transfer completion. What is the advantage of I2CMasterIntStatusEx if a tight loop is used in both cases?
Hello John,
I don't know of any examples using I2CMasterIntStatusEx in a while loop to wait for I2C transfers to finish. Can you provide an instance of that?
I would only use I2CMasterBusy for that and I am not sure what the advantage would be for I2CMasterIntStatusEx in a while loop...
I2CMasterIntStatusEx is best used in an ISR to take actions based on specific interrupt events.
Best Regards,
Ralph Jacobi
Hi Ralph,
I should have said it was not a TI example. I agree maybe a little time could be saved handling this on an interrupt but not by checking int status. It is example 1 in this link:
It is just that the Tiva I2C code is just kicking my butt a bit and some of the descriptions ain't none too wordy. So I forage for what works.
Thanks,
John
I always think twice about situations like I2C where there is a while (TheCowsHaven'tComeHome) termination. Some of our schedulers are not pre-emptive and potential to not run-to-completion gives me pause. I usually modify these so there can be a graceful exit rather than have the watchdog tag my backside. Speaking of same, I refactored a simple I2C write routine and guess where the code stops?
Hi John,
Thanks for the reference.
I don't really like that implementation at all. It probably works fine, but I've never once directed a customer to use that approach so if it has any shortcomings I am not aware.
Maybe what will help you more is this app note: https://www.ti.com/lit/pdf/spma073
If there is concern about it from a scheduler standpoint I would think it would make more sense to have it be more interrupt driven instead then. That way you can avoid any of those while loops.
Best Regards,
Ralph Jacobi
Thanks.
Sometimes it works out easy to check delta time while checking I2CMasterBusy(). Fortunately this board won't be very busy, just read some data from an IMU chip over I2C then push it out on a CAN bus. So I can twiddle my thumbs while waiting on I2C at 400Kbps. The 123 should have no problem with that.