How to use cubemx to genrate code to add multiple I2C salve devices or sensor to STM32F423 I2C channel in same port.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-15 3:42 PM
Am creating a I2C communicaton hub , where i have more than 20 sensor which is having I2C comunication. thing is i need connect all this sensor with in 2 I2C port. am getting confusion. how to write the code implementtion for same above using stm cube.
- Labels:
-
I2C
-
STM32CubeMX
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-15 8:31 PM
Why not use a step by step approach? Have a look at my shared GPIO I2C bus implementation code in this forum? It includes some examples of exotic I2C sensors and has a generic definition of slave device (struct) which works fine. Later, you can replace the SW I2C by HW I2C at low level.
CubeMX has yet to generate code by drag and drop a BOM (bill of material) and user's prefferences.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-15 11:55 PM
> thing is i need connect all this sensor with in 2 I2C port. am getting confusion
The I2C bus was designed for this purpose, he uses addresses to differ between devices.
Be aware that many slave devices have fixed addresses, or very limited options to set the address. Just like with TCP/IP and CAN, the bus will stop working if addresses are not unique.
If Cube could spit out all the required application code by itself, you would not be needed anymore.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-16 7:26 AM
If you have many identical sensors with only 1 pin to have 2 possible slave address, you are in luck: you can use an I2C IO Expander connected to all these address select pins of these sensors and use the io expander to have one sensor with a unique address among other so you can pinpoint which one to talk to. Handy when having lots of sensors to put in a thermal chamber....
