2024-05-16 04:20 AM
Hi!
As i know, there are differents modes of spi: Single(or standard), dual and quad SPI. On stm32cubeIDE/CubeMX i can see there are different selections: SPI and Quad-SPI. But i was wondering how can i differenciate between standard and dual SPI. I have these code lines, which mode am i using and how to configure the other way?
hspi3.Instance = SPI3;
hspi3.Init.Mode = SPI_MODE_MASTER;
hspi3.Init.Direction = SPI_DIRECTION_2LINES;
hspi3.Init.DataSize = SPI_DATASIZE_4BIT;
hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi3.Init.NSS = SPI_NSS_HARD_OUTPUT;
hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi3.Init.CRCPolynomial = 0x0;
hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
hspi3.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
hspi3.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
hspi3.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi3.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi3.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
hspi3.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
hspi3.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
hspi3.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
hspi3.Init.IOSwap = SPI_IO_SWAP_DISABLE;
if (HAL_SPI_Init(&hspi3) != HAL_OK)
{
Error_Handler();
}
Thank you so much for your help!
Hope i explained it well!
Solved! Go to Solution.
2024-05-17 06:29 AM
Hello @rubenles ,
According to Reference manual, SPI supports many standards like as Motorola standard and TI mode standard.
SPI Motorola mode is selected by default after a device reset. For more information about the SPI protocol, I recommend you take a look at Guidelines for enhanced SPI communication on STM32 MCUs and MPUs application note.
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-05-17 02:08 AM
Hello @rubenles
The SPI and the QUADSPI are two different interfaces:
In this code you configure the SPI3 instance as master mode.
hspi3.Instance = SPI3;
hspi3.Init.Mode = SPI_MODE_MASTER;
The STM32CubeMX can help you to configure the other modes.
Also, I recommend you to take a look at the device reference manual and precisely SPI and QUADSPI sections and at AN4760 application note.
I hope this answer your 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-05-17 04:48 AM
Thank you for your response @KDJEM.1 . Everything understood with perfection but i have to clearify one more thing.
Using "SPI" protocol, without the QUAD, just "SPI" it is assumed that the protocol is "STANDARD SPI"?
Thank you in advance.
2024-05-17 06:29 AM
Hello @rubenles ,
According to Reference manual, SPI supports many standards like as Motorola standard and TI mode standard.
SPI Motorola mode is selected by default after a device reset. For more information about the SPI protocol, I recommend you take a look at Guidelines for enhanced SPI communication on STM32 MCUs and MPUs application note.
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-05-19 11:03 PM
Thank you @KDJEM.1 :)