issue faced during transmission of data in STM32F072RB using SPI DMA
Hi,
I am using STM32F072RB-disco board to implement SPI communication with an external system.
SPI MODE :Slave mode full duplex communication (for both SPI)
From the external system I have to receive and transmit the 63 bytes of data with 2 SPI's (SPI1 & SPI2).
The data is coming continuously i.e. every one millisecond . I need to receive the data's using SPI1 and SPI2 simultaneously.
I have to implement simultaneous SPI(SPI1 & SPI2) should send and receive data's.
for SPI1 & 2, I am facing the following issues
using HAL_SPI_TransmitReceive_DMA function I am not able to receive 63 bytes of data as expected (data alignment issues) and transmission is not happening(not able to transmit data).
I also implemented the SPI transmit/receive DMA separate function using the HAL library.(please refer to commented section in the below code)
The code below refer to what I have implemented.
while (1) {
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
while (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_4) == GPIO_PIN_RESET)//cs pin for spi1
;
while (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_4) == GPIO_PIN_SET)
;
SPI1_Communication();
while (HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_12) == GPIO_PIN_RESET)//cs pin for spi2
;
while (HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_12) == GPIO_PIN_SET)
;
SPI2_Communication();
static void SPI1_Communication(void) {
// SPI1 communication
// HAL_SPI_Receive_DMA(&hspi1, (uint8_t*) aRxspi1Buffer, 63);
// HAL_SPI_Transmit_DMA(&hspi1, (uint8_t*) aTxspi1Buffer, 63);
HAL_SPI_TransmitReceive_DMA(&hspi1, (uint8_t*) aTxspi1Buffer,
(uint8_t*)aRxspi1Buffer, 63);
}
static void SPI2_communication(void) {
// SPI2 communication
HAL_SPI_TransmitReceive_DMA(&hspi2, (uint8_t*) aTxspi2Buffer,
(uint8_t*) aRxspi2Buffer, 63);
// HAL_SPI_Receive_DMA(&hspi2, (uint8_t*) aRxspi2Buffer, 63);
// HAL_SPI_Transmit_DMA(&hspi2, (uint8_t*) aTxspi2Buffer, 63);
}I kindly request for suggestions and corrections , help me to fix this issue.
Thanks
Sudharshan.
