This is a follow/new insight regarding my previous question Messages for SPI protocol.
One idea from that question is to use the SS line to know a new message is being sent from the master to the slave. The master will be the STM32 and the slave the Arduino, see below:
Slave <--- Master
Arduino (SPI) STM32
| ^ ^ ^
V | | |
RS485/DMX512 3x UART/MIDI
The Master receives MIDI signals from various sources, processes them, transmits (changed) MIDI messages back and sends SPI messages to the Arduino which sends the DMX signals.
So far so good, I am currently implementing the Arduino code (including a Windows test application).
The reason I use an Arduino for RS485/DMX is mainly because I couldn't get it to work on an STM32, but also to relieve the STM32 processing power.
However, I need more SRAM on the Arduino, so I will use a SPI SRAM chip (32K256). The problem is, that I'm not sure if I can let the Arduino be the slave.
SPI RAM 32K256
|(SPI)
V
Slave <--- Master
Arduino (SPI) STM32
| ^ ^ ^
V | | |
RS485/DMX512 3x UART/MIDI
Some things I considered:
- Making the Arduino the Master, and poll to the STM32 (resulting in my useless poll events likely).
- Keeping the STM32 master and when a send fails to retry.
- Using I2C but I think SPI is easier to implement.
Afaik the communication needs to be completely synchronous, but I'm not sure if there is some 'relaxation' due to buffers inside the SPI peripherals.
Some more background information about the entire project:
- The STM32 read inputs from various MIDI inputs (synthesizers mainly)
- At a later stage I might also add other inputs (non MIDI).
- The STM32 processes these messages and sends out MIDI messages and commands for the Arduino slave.
- The Arduino slave processes the messages which can be something like (make all front DMX lights fade in and out between red and blue, make lights X and Y green, switch on stroboscope with speed 50, etc). These messages all have the same length (18 bytes).
- For each DMX light (17 so far, but can increase in future), I have a class (instance) that keeps information (max 64 bytes) per light, this will not fit in an Arduino, so I use external SRAM.
- As often as possible (but at least every few ms), the Arduino processes a light, by reading its data from the SRAM, and changing the fade colors, and also processes new commands from the master if there are any. And finally saving back the changed data to SRAM.
Any insights would be helpful.