Synchronizing SPIs

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Synchronizing SPIs

Postby Deouss » Tue Jan 28, 2020 3:50 pm

I would like to send signals from all SPIs at exact time so I know when all transmissions end at same time
Are they synchronized by default or must be configured?

I also noticed there are special functions for SPI pins as output:

(gpio_sig_map.h)

Code: Select all

#define SPID4_IN_IDX			128
#define SPID4_OUT_IDX			128
#define SPID5_IN_IDX			129
#define SPID5_OUT_IDX			129
#define SPID6_IN_IDX			130
#define SPID6_OUT_IDX			130
#define SPID7_IN_IDX			131
#define SPID7_OUT_IDX			131
#define HSPID4_IN_IDX			132
#define HSPID4_OUT_IDX			132
#define HSPID5_IN_IDX			133
#define HSPID5_OUT_IDX			133
#define HSPID6_IN_IDX			134
#define HSPID6_OUT_IDX			134
#define HSPID7_IN_IDX			135
#define HSPID7_OUT_IDX			135
#define VSPID4_IN_IDX			136
#define VSPID4_OUT_IDX			136
#define VSPID5_IN_IDX			137
#define VSPID5_OUT_IDX			137
#define VSPID6_IN_IDX			138
#define VSPID6_OUT_IDX			138
#define VSPID7_IN_IDX			139
#define VSPID7_OUT_IDX			139


So f.ex. code - gpio_matrix_out(MY_PIN, SPID4_OUT_IDX, 0, 0)
will map my MY_PIN to first bit of SPI data?
What are those signals for SPI functions and how does that work?

Thanks

Aussie Susan
Posts: 44
Joined: Thu Aug 22, 2019 3:48 am

Re: Synchronizing SPIs

Postby Aussie Susan » Wed Jan 29, 2020 2:30 am

I suspect this is an 'X-Y' problem; therefore what are you trying to do that requires synchronised SPI exchanges?
You *might* be able to do something like:
- make one SPI module the master and all others slaves
- the master will generate the SCK signal and all others will use that
- because SPI is an exchange process, if you connect pairs of SPI modules together in the usual manner (output of one to the input of the other) but configure both as slaves, then both will respond the to the master clock at the same time and so both will try to send and receive at the same time and so still exchange their values.
- All of the slaves could share the \CS\ line
I've certainly not tried this but, there again, I can't think of a situation where I'd want to synchronise multiple SPI exchanges.
Susan

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Re: Synchronizing SPIs

Postby Deouss » Wed Jan 29, 2020 3:11 pm

Thanks Susan. It is complicated, I'm trying to synchronize 2 or more devices that should read data at exact time.
I will look for more solutions I think.
Looks like gpio_matrix_out can map bits 4-7 of SPI data byte to individual pins which may help if it works

Aussie Susan
Posts: 44
Joined: Thu Aug 22, 2019 3:48 am

Re: Synchronizing SPIs

Postby Aussie Susan » Thu Jan 30, 2020 2:16 am

Now I am more confused.
SPI is a serial exchange protocol which means that each bit of a value being sent is presented to the MOSI (for a master - MISO for a slave device) pin in line with the SCK transitions.
Therefore I have no idea how this relates to the gpio_matrix_out function.
You don't mention what the other devices are but if they all take the same 'command' value and all start reading data at exactly the same time (say at the end of the reception of the command data) then just tying all of the slave devices MOSI and \CS\ pins together would let them all receive the same command at the same time.
You would probably still need separate SPI modules to read in the results from each device - assuming they are all sent back via the SPI interface.
Susan

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Re: Synchronizing SPIs

Postby Deouss » Thu Jan 30, 2020 4:15 pm

Aussie Susan wrote: SPI is a serial exchange protocol which means that each bit of a value being sent is presented to the MOSI (for a master - MISO for a slave device) pin in line with the SCK transitions.
Therefore I have no idea how this relates to the gpio_matrix_out function.
Yes but normally all bits go through one pin and I know other MCUs are capable of mapping sequence of bits/signals in a transmitted byte to the pins. Usually 8bits/8pins or 16/24/32. I wil try it when have more time but in case of esp32 that would be only half a byte per spi

Aussie Susan
Posts: 44
Joined: Thu Aug 22, 2019 3:48 am

Re: Synchronizing SPIs

Postby Aussie Susan » Fri Jan 31, 2020 1:57 am

Got it now - you are talking about Quad SPI (QSPI)
Susan

Who is online

Users browsing this forum: Bing [Bot] and 51 guests