i'm using this serial topology to connect my STM32F1 slaves together to a master ESP32.

They are in total 10 STM32F1 slaves and one master:

enter image description here

With this type of wiring i'm sure that only one slave per time will talk back to master (when requested), now here comes the problem, basically i need dynamic addressing of slaves: they can be many (up to 30) and i need to access in order the slave devices.

In order to solve the "dynamic addressing" problem i'm thinking about that:

  • The first slaves will be plugged in and will send to the master his default address (i.e.: 0xFF)
  • The master will check if the address is used and then reply back to the device with the first available address (i.e.: 0x01)
  • The slave will get back the response from the master and set an internal variable with the new address (maybe it's a good idea to store the variable in a EEPROM like M24C02: enter link description here)

Starting from the next cpu cycle, the master will ask sequentially to all enumerated slaves to (for example) do an analog read using this workflow:

  • The master will send a message to the serial bus with address 0x01 asking to do an analog read
  • The respective slave will handle the request, read the analog input and then reply back to the master

I think that this can work, but i've not found any kind of this implementation...maybe i'm totally out of mind?

New idea and concept

Guys, what do you think about sequentially power up the circuits and using the same mechanism to assign dynamically the address?

This assumption will avoid me to save the assigned id to the eeprom and some other id software function defined functionalities like address reset, etc...

It can be a good (and dynamic) method to solve the problem, about that, how I can implement this sequential power up?

  • 1
    \$\begingroup\$ Other than cryptic "Starting from the next cpu cycle" your automatic address configuration is as good as any. I would add the call to 0xFF slave as last call in your enumeration loop and also mark non-responding IDs for reuse later. This way you can add/remove slaves anytime. You also need a procedure to reset slave ID when it is removed from the bus. \$\endgroup\$ – Maple May 29 '20 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.