cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to configure the QSPI as slave to receive data from an external ADC

Simon86
Associate II

Hello,

I'am trying to connect the AD7771 (https://www.analog.com/media/en/technical-documentation/data-sheets/AD7771.pdf) with a STM32F413. The question is, if it is possible to configure the QSPI as slave to receive the data from the AD7771 via DOUT0-DOUT3. In this case, the AD7771 is the master and provides the CLK. How can I configure the QSPI that the CLK Pin of the µC is an input and uses the CLK of the AD7771?

FYI: I have already connected the DOUTs to the normal SPIs and it works fine. The problem is that their are not enough SPIs to connect the other "modules" and so I want to save the normal SPIs which are connected to the AD7771.

Thanks for your support.

6 REPLIES 6
S.Ma
Principal

No(t yet?) ==> add to STM32 Wish list ?

If you are not using all SPI at the same time, you can use alternate pins for the SPI to implement a bus MUX. (MODER/AF GPIO bit fields).

Same for I2C or master serial interfaces

Simon86
Associate II

Ok. Thanks for your quick answer. Good idea to implement a bus mux. I will try it.

Andreas Bolsch
Lead II

The QSPI is strictly master-only as it's intended for external memory, and transfer modes are restricted when compared to the normal SPI interfaces, e. g. byte oriented.

Jaroslav BECKA
ST Employee

Another solution might be using SAI (Serial Audio Interface) or PSSI (Parallel Slave Synchronous Interface), if available on your product.

Alternatively, you could use GPIO, DMA and TIM. Please take a look into AN4666: Parallel synchronous transmission using GPIO and DMA.

There is an associated software package X-CUBE-PARAL-COM.

https://www.st.com/en/embedded-software/x-cube-paral-com.html

https://ez.analog.com/data_converters/precision_adcs/w/documents/2855/interfacing-the-ad7768-ad7768-4-to-a-microcontroller

Hi, I have similar problem with reading data from AD7771 via DOUTx line (I want to read all 8 channels on 1 line DOUT_0)). 1 channel has 4 bytes (1 for header an 3 for ADC data)

I want to use SAI interface. I tried to read data like that, but there are some weird data HAL_SAI_Receive(&hsai_BlockB3,(uint8_t *) GlSAI_DMA_Buff, 8, 0xffffff);

What I am not sure about is:

  • hsai_BlockB3.SlotInit.SlotActive - What does it mean? I want to have 8 channels on DOUT_1 line - so there is 32 slots? Or all this "pack" is taken as 1 slot?
  • hsai_BlockB3.Init.DataSize  - for me it should be 32? (1 channel sends 4 bytes)
  • hsai_BlockB3.FrameInit.FrameLength = 256; - it sounds good for me when I want to read 8 channels (1 channel have 1 B header and 3 B for ADC data) 4x8x8 = 256 bits
  • what bout that? hsai_BlockB3.FrameInit.ActiveFrameLengt
  • what bout that? hsai_BlockB3.SlotInit.SlotNumber

All my settings is here:

hsai_BlockB3.Instance = SAI3_Block_B;

hsai_BlockB3.Init.Protocol = SAI_FREE_PROTOCOL;

hsai_BlockB3.Init.AudioMode = SAI_MODESLAVE_RX;

hsai_BlockB3.Init.DataSize = SAI_DATASIZE_8;

hsai_BlockB3.Init.FirstBit = SAI_FIRSTBIT_MSB;

hsai_BlockB3.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;

hsai_BlockB3.Init.Synchro = SAI_ASYNCHRONOUS;

hsai_BlockB3.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;

hsai_BlockB3.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY;

hsai_BlockB3.Init.SynchroExt = SAI_SYNCEXT_DISABLE;

hsai_BlockB3.Init.MonoStereoMode = SAI_STEREOMODE;

hsai_BlockB3.Init.CompandingMode = SAI_NOCOMPANDING;

hsai_BlockB3.Init.TriState = SAI_OUTPUT_NOTRELEASED;

hsai_BlockB3.Init.PdmInit.Activation = DISABLE;

hsai_BlockB3.Init.PdmInit.MicPairsNbr = 1;

hsai_BlockB3.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE;

hsai_BlockB3.FrameInit.FrameLength = 256;

hsai_BlockB3.FrameInit.ActiveFrameLength = 1;

hsai_BlockB3.FrameInit.FSDefinition = SAI_FS_STARTFRAME;

hsai_BlockB3.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW;

hsai_BlockB3.FrameInit.FSOffset = SAI_FS_FIRSTBIT;

hsai_BlockB3.SlotInit.FirstBitOffset = 0;

hsai_BlockB3.SlotInit.SlotSize = SAI_SLOTSIZE_32B;

hsai_BlockB3.SlotInit.SlotNumber = 1;

hsai_BlockB3.SlotInit.SlotActive = 0x00000000;

Thank you for any advice, Jan.

Hi @Community member​ 

Here are the answers to your questions:

hsai_BlockB3.SlotInit.SlotActive - What does it mean? I want to have 8 channels on DOUT_1 line - so there is 32 slots? Or all this "pack" is taken as 1 slot?

Slot active would be the number of slots that you intend to read, irrespective of what the DOUT_1 actually sends out.

(1 << slots_per_frame) - 1 would be the value here.

hsai_BlockB3.Init.DataSize - for me it should be 32? (1 channel sends 4 bytes)

Yes, the data size represents the data size of one slot, which in your case would be 32.

hsai_BlockB3.FrameInit.FrameLength = 256; - it sounds good for me when I want to read 8 channels (1 channel have 1 B header and 3 B for ADC data) 4x8x8 = 256 bits

The frame length value needs to be calculated as follows:

(data_size +data_offset) slots_per_frame;

In this case, it would be (32+0)*(8) = 256 .

what bout that? hsai_BlockB3.FrameInit.ActiveFrameLengt

Active frame length does not hold any significance in case of operation in slave mode.

what bout that? hsai_BlockB3.SlotInit.SlotNumber

Slot number would be the number of slots per frame. In this case it would be 8 (8 channels) 

Thanks,

Janani Sunil