cancel
Showing results for 
Search instead for 
Did you mean: 

What should be the value of bufferSize in HAL_SPI_TransmitReceive_DMA?

jd
Associate

When I set my SPI to full duplex mode and CRC is enabled then what should be the value of bufferSize in HAL_SPI_TransmitReceive_DMA(&hspi1, (uint8_t*)aTxBuffer, (uint8_t *)aRxBuffer, bufferSize ) function?

for ex size of buffers is 4 bytes (excluding CRC bytes). Then What should be the value of bufferSize in following function?:

HAL_SPI_TransmitReceive_DMA(&hspi1, (uint8_t*)aTxBuffer, (uint8_t *)aRxBuffer, bufferSize ).

Note: CRC is enabled on both master and slave side.

4 REPLIES 4
Imen.D
ST Employee

Hello jd,

Please follow the UM1905 User Manual "Description of STM32F7 HAL and Low-layer drivers", it will help you on how to use SPI functions and to see their descriptions and structures.

https://www.st.com/content/ccc/resource/technical/document/user_manual/45/27/9c/32/76/57/48/b9/DM00189702.pdf/files/DM00189702.pdf/jcr:content/translations/en.DM00189702.pdf

 0690X000006C19fQAC.pngYou can also review the SPI example within STM32CubeF7, it will help you to develop your own application and use functions:

STM32Cube_FW_F7_V1.12.0\Projects\STM32F767ZI-Nucleo\Examples\SPI\SPI_FullDuplex_ComDMA

With Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

The question I think relates to the awkward mechanics of the CRC generation and checking on the SPI bus, for which I'm not aware of any robust examples.

I see ZERO test cases across a number of libraries. If the hardware and software has been validated, please provide a working proven example using a real world component supporting CRC via SPI. Thanks. @STOne-32​

/**

 * @brief Transmit and Receive an amount of data in non-blocking mode with DMA.

 * @param hspi pointer to a SPI_HandleTypeDef structure that contains

 *              the configuration information for SPI module.

 * @param pTxData pointer to transmission data buffer

 * @param pRxData pointer to reception data buffer

 * @note  When the CRC feature is enabled the pRxData Length must be Size + 1

 * @param Size amount of data to be sent

 * @retval HAL status

 */

HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData,

                                             uint16_t Size)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Imen.D
ST Employee

Hello @Community member​ ,

Your request is raised internally to the relevant team.

Thank you for your contribution.

Kind Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

Hello,

Regarding this request, and at this time, there is no STM32 board with a SPI chip supporting CRC.

So, there is no plan to support this request.

Regarding the buffer Size question: Inside HAL, the buffer length for transmission/reception is excluding the CRC size. CRC is received and computed directly by the SPI peripheral and this is transparent for user.

If CRC receive is not well, an error is generated, otherwise, HAL_OK is returned by the API.

Please find attached the SPI presentation that can help you to understand the fonctionement of SPI IP.

This document is based on STM32L4 and also applicable for STM32F7.

Kind Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen