How to make several I2C (slave) addresses in STM32.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-25 11:45 PM
Hello,
I am trying to connect RaspberryPi (master) with STM32 (slave) via I2C. STM has to "simulate" several devices (exactly 10) on the I2C bus. The problem is that I can set max 2 addresses (at least in Cube - HAL libraries). Ideally it would be like this: RP3 sends a command, STM32 generates an interrupt regardless of the address (1 byte) of command, and I can read the entire buffer with the address and decide what to answer depending on it.
Is such a thing possible? Only 2 devices are physically connected to the I2C bus and there will be no conflicts for sure.
I'm struggling with it all weekend... Anyone have any idea? I will be grateful for any suggestion.
Thank you,
Sebastian
- Labels:
-
I2C
-
STM32Cube MCU Packages
-
STM32F1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-26 12:11 AM
You did not care to tell us which STM32 are you trying to use. There are several different I2C implementations across the various STM32 families, some support only two slave addresses, some support more, although not in a trivial manner. See e.g. the 'F0 I2C chapter, I2C slave mode subchapter, and the I2C_OAR2 register's description.
> I can set max 2 addresses (at least in Cube - HAL libraries)
Read the fine manual before clicking, if you want to do something out of usual.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-26 1:46 AM
Thank you for your answer. You're right, I didn't say which stm I use. It is: stm32f105vct6.
Of course, I read all the datasheets I found. But unfortunately I didn't find a direct answer there. I thought it could be done at the HAL level, but I think I have to go deeper to the registers..
Sebastian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-27 2:16 AM
AFAIK the 'F1 don't have the I2C module which has masks on I2C_OAR2, so you can't do that with the 'F105.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-08-27 6:37 AM
I spent some time on this yesterday and today. It seems that HW checks by itself if the addresses match and then generates an interrupt. I haven't found a place in code where I could manually check if the address is ok or not: /
If the address doesn't match, it just waits for the next start condition. Suck :( There really is no possibility to somehow get around this?
Sebastian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-09-03 12:53 PM
Well, if the I2C master does not run the I2C protocol too fast and the slave is fast enough, you can simply omit the I2C hardware and bit-bang the protocol.
JW
