2024-06-05 10:56 PM
Hello,
Could you please help me with handling a same channel I2C protocol between 2 core.
I have two devices connected on the same I2C channel(I2C1). I want to run one device on M7 core and another on M4 core. How to handle the communication between the devices and the microcontroller so that there is no interference during communication?
- Regards
Hrishikesh
Solved! Go to Solution.
2024-06-12 01:21 AM - edited 2024-06-12 01:22 AM
As I said you need to handle that with semaphores. I'm not expert of i2c but you need to test.
If you face a synchro issues, I think you can opt with my first scenario: one core handles the comm + one slave and the second core handles the second slave.
Hope I answered your question.
2024-06-06 04:08 AM
https://www.i2c-bus.org/multimaster/ is your friend
2024-06-06 05:13 AM
Hello,
Thank you for the reply. The link which you have shared provides the concept or direction for implementation.
Are there any resources, which provides the method to do so. May be a sample code or the module which should be used.
-Regards
2024-06-06 05:32 AM
i don't have any resources regarding this topic
but to be honest i would question the concept. why would you handle the same bus from 2 controllers? what's the usecase for this? handle the i2c with one controller and exchange data between controllers if needed
2024-06-06 05:46 AM
Hello,
Not clear what do you mean by this: " I want to run one device on M7 core and another on M4 core"
Do you have two I2C slave devices connected on I2C1 interface and you need to handle one slave data with CM7 and the other one with CM4?
2024-06-06 06:32 AM
Hello,
Yes I have two I2C slave devices on I2C1 channel. I want two handle them on separate cores.
My question is how can it be done without causing interference between the devices during communication.
-Regards
2024-06-06 06:55 AM
I think you can implement that by data exchanges between cores:
One core will handle the communication of the two slaves and manage the data of one slave. It will send/receive data of the second slave to the second core.
Refer to that article: https://community.st.com/t5/stm32-mcus/stm32h7-dual-core-how-to-communicate-between-cm4-cm7/ta-p/49656
and especially: AN5617 Application note: STM32H745/755 and STM32H747/757 lines inter-processor communications
2024-06-06 10:04 PM
Hi,
Thank you for the suggestion. I will try the same.
But out of curiosity, isn't it possible for the two cores to work on same I2C channel without any interference. Maybe some flag or interrupt like arrangement which will indicate whether the channel is busy or not.
So in my application I wouldn't prefer to exchange the entire data set of a device from one core to another. For me it will be convenient if the two cores handle the two I2C devices separately and further process the data independently.
-Regards
2024-06-11 07:25 AM
Hello,
It's possible to manage the same instance of I2C channel with two cores but you need to use semaphore mainly with HW semaphore to lock/unlock the ownership of the peripheral at a given time by a given core.
2024-06-11 09:55 PM
Thank you for the suggestion.
I would like to know, should this be the efficient way to handling the device communication. Will there be any clashes or possibility of synchronization error?
-Regards