cancel
Showing results for 
Search instead for 
Did you mean: 

Best practices for I2C driver architecture

domenicocelentano
Associate II

Hi,

I want to use a single low-level module to handle up to three I2C buses at the same time using the HAL library and using the interrupt for all communications with the relative callback. Is it possible to use a single write/read/callback function for all transactions on all three buses at the same time. Are there any problems if the callback is interrupted to handle another interrupt of another I2C bus with higher priority?

Best regards,

Domenico

2 REPLIES 2
Karl Yamashita
Lead III

As long as you have different data buffer or structure for each bus then you will be fine. But if you are sharing the same data buffer, then you'll get conflicts as 1 of the bus will over write the other bus data.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
TDK
Guru

Should be no problems doing this with HAL. Get one instance working first and it should be straightfoward to move to multiple. They will all use different handles.

I2C interrupts pre-empting should not cause issues. However I2C is so slow compared to interrupt execution speed that I'd set them all at the same priority.

 

If you feel a post has answered your question, please click "Accept as Solution".