Detecting when I2C bus becomes IDLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-09 11:33 AM
STM32F302K8 here. According to the manual, there is a flag in the ISR to see if the bus is busy, but it does not generate an interrupt when cleared. Also the STOP condition says it is only generated while you are the master and generate it, or are the previously selected slave. In other words, if another master is talking to another slave on the bus when you want to transmit, you won't get a STOP interrupt when it's done, so how are you supposed to know when the bus is free so you can try to transmit?
- Labels:
-
I2C
-
STM32F3 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-09 1:14 PM
I2C_ISR_BUSY can be checked to see if the bus is busy. You can try to send the data you want whenever. If you lose arbitration, an interrupt can be generated and you can try again later.
Edit: same as I2C_SR2_BUSY on the F4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-10 5:57 AM
Of course... my point is how do you detect when "later" arrives? You need an interrupt when the bus goes idle but apparently the controller can't generate one reliably.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-10 6:29 AM
There's no interrupt tied to this bit. You just need to check it. Check it in a periodic timer interrupt. Or not, and just send data until it gets through. Those are your options.
You could hack something together with a timer and an EXTI line, but I wouldn't suggest it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-10 6:32 AM
Send until it gets through means that the cpu can't service other tasks. A periodic timer means you waste time with an idle bus where you could be sending, but aren't because the timer hasn't fired yet. This is a shame. It seems like a design defect of this I2C controller implementation.
