cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to get SPI slave working with DMA controller with CRC enabled

arnold_w
Senior
Posted on March 31, 2016 at 14:11

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
3 REPLIES 3
arnold_w
Senior
Posted on March 31, 2016 at 14:53

The following change in the HAL-layer seems to solve the problem:

HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size)
{
.
.
.
hspi->pTxBuffPtr = (uint8_t*)pTxData;
hspi->TxXferSize = Size;
hspi->TxXferCount = Size;
hspi->pRxBuffPtr = (uint8_t*)pRxData;
hspi->RxXferSize = Size;
hspi->RxXferCount = Size;
.
.
.
}
status = HAL_SPI_TransmitReceive_DMA(&hspi2, transmitDMAbuffer, receiveDMAbuffer, DMA_RECEIVE_BUFFER_SIZE);

HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t TxSize, uint16_t RxSize)

{ . . . hspi->pTxBuffPtr = (uint8_t*)pTxData; hspi->TxXferSize = TxSize; hspi->TxXferCount = TxSize; hspi->pRxBuffPtr = (uint8_t*)pRxData; hspi->RxXferSize = RxSize; hspi->RxXferCount = RxSize; . . . } status = HAL_SPI_TransmitReceive_DMA(&hspi2, transmitDMAbuffer, receiveDMAbuffer, DMA_RECEIVE_BUFFER_SIZE, DMA_RECEIVE_BUFFER_SIZE + 1);
arnold_w
Senior
Posted on March 31, 2016 at 15:58

I guess I was too quick to conclude that it was working. If I run several times this is what I get:

1st attemp: Everything ok.

2nd attempt: The received data is correct, but I get a CRC error and I never get a SPI_DMATransmitReceiveCplt interrupt on the transmit DMA stream (stream 4).

3rd attemp: This starts with an interrupt from the receive DMA stream (stream3), but no interrupt flag is set. Everything else is ok.

4th attempt: The received data is correct. but  I never get a SPI_DMATransmitReceiveCplt interrupt on the transmit DMA stream (stream 4).

5th attempt: This starts with an interrupt from the receive DMA stream (stream3), but no interrupt flag is set. Everything else is ok.

Anybody know what's wrong?
arnold_w
Senior
Posted on April 04, 2016 at 18:00

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6de&d=%2Fa%2F0X0000000bsH%2FBGRMTlN2GYK2juCdvM2pe9vUzCzitjb6tYvHwEsqK8s&asPdf=false