2016-03-31 05:11 AM
2016-03-31 05:53 AM
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);2016-03-31 06:58 AM
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?2016-04-04 09:00 AM