2024-07-16 10:37 PM - edited 2024-07-17 04:49 AM
Hi Experts,
Is it possible to use STM32H5 OctoSPI interface (configured as Dual-Single-SPI) as two individual transmit-only SPI masters?
Requirements:
1. Two devices connected to MCU are identical but receive different data
2. Devices are not a memory
3. No data needs to be received by MCU4. No simultaneous write is required (edit after first reply: Simultaneous write is required)
If such configuration is possible, how will HAL code look like?
Which of OCTOSPI_IO0, IO1, IO2, IO3 pins are can be configured as 'MOSI'?
Edit: I realized 'Dual SPI' and 'Dual-Single SPI' are a different things. Changed post subject to 'Dual-Single SPI'
2024-07-17 03:28 AM - edited 2024-07-17 03:29 AM
Hello @RustleOfCicadaTHS and welcome to the Community :),
I think you want two connect two devices with only OCTOSPI interface using single-SPI mode.
There are 2 possible solutions to do that
Notes:
Is my reply answer you request?
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-07-17 04:47 AM - edited 2024-07-17 04:57 AM
Hi @KDJEM.1 , thanks for the reply.
> I think you want two connect two devices with only OCTOSPI interface using single-SPI mode.
Actually yes, use of single-SPI would satisfy my requirements based on Solution2 you provided - thus I believe my hardware will still be usable anyways.
However, Solution1 is closer to what I had in mind. It's good to know that Memory can be selected using a register. Question1: Does Memory selection work at runtime without time consuming OctoSPI peripherial reconfiguration? (assuming two identical devices).
I've researched the topic a bit further and found Dual-Flash configuration in AN4760 (Figure 13 and Table 9).
I believe that Dual-Flash = (Dual-Single or Dual-Dual or Dual-Quad) SPI that can be selected in CubeMX.
Based on this forum post you've previously anwsered I have a following question:
Question2: What if we wanted to write to both devices simultaneously using Dual-Flash (Dual-Single) SPI configuration? (assuming that data buffers for devices 1 & 2 were interleaved ahead of time, e.g.: [Byte1Dev1] [Byte1Dev2] [Byte2Dev1] [Byte2Dev2] )
Question3: Is it possible to mirror SPI CLK signal on additional pin to eliminate star connection (trace split in two) on PCB?
2024-07-17 04:00 PM
Q3: no, it is not possible to bring out the same SCK signal also on a different pin (just one or the other). I do not know what would happen if you configure two different pins with the "same" ALT to provide the same SCK output (interesting trial). I assume, MCU will take the last pin you have configured via ALT as QSPI SCK out.
You could use QSPI in order to send - in parallel - to two different chips. But just Tx (only MOSI used), Rx is not possible.
Based on your schematics: you would run QSPI in 4-lane-mode (real QSPI): on DIOx (e.g. bit 0) goes to one chip, the other DIOx (e.g. bit 2) goes to another chip. Both chips are selected at the same time (via NSS).
But: there is just one register for the CMD, ADDR, ALT, DATA sent via QSPI. You had to place the bits for each chip on the right bit position in the data word sent. You do not have two separate registers for each chip, just one for both and you have to merge the different bits into one register word. (effort, but possible).
If you do not need to write both chips really in parallel - you can use TWO separate NSS signals: select one chip, send, select the other chip and send. NSS can be also a regular GPIO signal (and use SW control for NSS).
Just to clarify some terms for better understanding how this QSPI device works in MCU:
Just configure the QSPI as you intent to use, use an oscilloscope and check if you get the signals as needed. Just to verify that the correct SPI transaction is generated (you do not need any external chip when doing just WRITEs).
BTW: why do you use QSPI (or OCTAL-SPI) device for it? Any regular SPI would do the same job.
QSPI device is a bit more complex in terms of config and use, e.g.: QSPI requires to setup a CMD, ADDR, ALT word before the DATA will be sent.
OCTAL or QUAD-SPI is intended for external memory devices whereas SPI is for any chip (also sensor chips and even SD Cards).
Remark: the STM32 OCTAL-SPI (or QUAD-SPI) is not really similar to a regular SPI. "Single-SPI" is not the same as on "regular" SPI (half-duplex vs. full-duplex, but you need just Tx/WRITE, OK anyway).
What is your intention?
a) two external chips written in sync, at the same time, but with different data (different MOSI)?
One NSS selecting both at the same time?
b) two external chips, with Tx-only SPI (Master, Tx-only), but you can select one and then the other?
(write both chips in a sequence)?
Two NSS and selecting one or the other?
a) works only with DUAL or QUAD-SPI mode and bit-manipulations in the data register (and CMD, ADDR, ALT registers)
b) works on regular SPI, or on OCTAL-SPI in "Single-SPI" mode, but with two NSS signals (you might handle as SW GPIO NSS signals)
2024-07-18 12:32 AM
Hi @tjaekel, thanks for answering
> What is your intention?
My main goal is to increase write data rate as much as possible, reading data from SPI is not used in this application. Being able to write to both Devices in sync would be ideal.
> why do you use QSPI (or OCTAL-SPI) device for it?
In my case remaining SPI peripherials are already occupied so I wanted to utilize OctoSPI to its full extend.
I'll try to test OCTOSPI peripherial on hardware as you suggested.
Apart from AN4760, does anyone have other sources of information regarding OCTOSPI Dual-Flash (Dual-Single) peripherials? Maybe code snippets, example projects?