Page 1 of 4

Messaging between multiple Maple Mini clones

Posted: Sat Aug 27, 2016 7:06 pm
by joevpt
I have a project which uses 6 arduino boards which I am porting to Maple Mini clones to benefit from 32 bit and higher clock rate. As currently written the project has one master I2C and five slave I2C. I've read that Slave mode is not implemented in the Maple Mini port for Wire and wonder what solution is recommended?
The slave cards already use SPI_2 to communicate with some peripheral devices, and the master card uses SPI_2 to communicate with an Ethernet and SD card.
The port is completed except for the interboard communications which is always from the master to one or more slaves.

Does anyone know whether the I2C library for STM32F1 will include a slave mode any time soon or does anyone have a suggestion for an alternative?

Thanks in advance..

Re: Messaging between multiple Maple Mini clones

Posted: Sat Aug 27, 2016 8:21 pm
by Pito
You may use uarts - they can do Mbits - and the slaves will be connected to the master in a star configuration, listening on the request from the master when the id match the particular id-slave will answer. If slaves' uart tx pins allow an open drain, you may connect all slave's txs to master's rx ("wired or") and all slave's rx to master's tx directly. I did it in eighties with PC vs several 8051s and it worked :). You need to create a simple protocol, where the master will send a request to all slaves, and only one slave will answer.. Details depend on your application, however.
You may use 9bit transfer, where the 9th bit set "1" will indicate it is the slave's address (you may address 256 slaves then).

Re: Messaging between multiple Maple Mini clones

Posted: Sat Aug 27, 2016 8:43 pm
by joevpt
Thanks Pito. I had created a daisychain from Master to Slave1 then Slave 1 to Slave 2 etc. A simple protocol with a condition to forward the message if it's not for this Slave works ok. This solution uses two Usarts per MCU.

I didn't realise I could join several Slave Tx and Rx together and then reversed to the master. This gives me the benefit of looking exactly like I2C as far as my project is concerned. It also saves one Usart per MCU.

Do I need to condition the Rx Tx lines in this case Maple mini clone) or can I simply connect them together.

Re: Messaging between multiple Maple Mini clones

Posted: Sat Aug 27, 2016 9:03 pm
by simonf
Pito wrote:You may use uarts - they can do Mbits - and the slaves will be connected to the master in a star configuration, listening on the request from the master when the id match the particular id-slave will answer. If slaves' uart tx pins allow an open drain, you may connect all slave's txs to master's rx ("wired or") and all slave's rx to master's tx directly.
I've used something similar. You can just use a single pull up resistor wire all the rx's together and wire the tx's to the rx's via a diode. CCTALK uses this method.
Messages usually take the form of.

<From><To><Length><........Data.......><Checksum>

The uP's receive all packets and just ignore ones where the "To" adress doesn't match its ignored. It may well be worth either sending an ACK data packet and/or checking the rx buffer on the tx uP matches the transmitted Packet IE the packet got onto the bus un-corrupted.

Re: Messaging between multiple Maple Mini clones

Posted: Sat Aug 27, 2016 9:13 pm
by joevpt
Thanks Simon for the connection clarification. Before I go do it, can I clarify that the pull-up is required on both lines and a diode is required on each tx line ?

Each MCU in this setup can therefore read every transmission and confirm its own message ( like Old Ethernet looking for a collision).

I like it!

Re: Messaging between multiple Maple Mini clones

Posted: Sat Aug 27, 2016 10:11 pm
by simonf
joevpt wrote:Thanks Simon for the connection clarification. Before I go do it, can I clarify that the pull-up is required on both lines and a diode is required on each tx line ?

Each MCU in this setup can therefore read every transmission and confirm its own message ( like Old Ethernet looking for a collision).

I like it!
As for the pull up resistor(s) it depends on the bus length etc like the old ethernet 10 base T you normally had a terminator at each end. But it will depend on the length and thus the capacitance of the bus the longer the bus the more capacitance and the lower the resistor. I use 10K on a 30cm Bus. Yes you need a signal diode for each tx, the tx goes low when transmitting so the cathode goes to tx and anode to rx. Its a really cheap network.

The latest version of STM32 has TX and RX buffering so handling the packets is even easier.

Re: Messaging between multiple Maple Mini clones

Posted: Sat Aug 27, 2016 10:45 pm
by joevpt
Great Simon, and again thanks for the fast reply. I'll get to this tomorrow. 30 cm is more than enough for me so I will use some 10k resistors.

Re: Messaging between multiple Maple Mini clones

Posted: Sat Aug 27, 2016 11:05 pm
by RogerClark
If you get this working, could you let us know and post a small schematic diagram

Thanks

Roger

Re: Messaging between multiple Maple Mini clones

Posted: Sat Aug 27, 2016 11:18 pm
by simonf
joevpt wrote:Great Simon, and again thanks for the fast reply. I'll get to this tomorrow. 30 cm is more than enough for me so I will use some 10k resistors.
You only need two resistors one at each end you may get away with one. The higher the baud rate the lower the resistor value.

Re: Messaging between multiple Maple Mini clones

Posted: Sun Aug 28, 2016 1:56 pm
by rreignier
Hi,
What you trying to do seems to be what ST call Multiprocessor communication as explained at paragraph 27.3.6 in the F103 Reference Manual (RM0008).
I have never tried that but just wanted to let you know that is is documented by ST.