2024-07-16 10:58 PM
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.
2024-07-19 01:55 AM
Hello @Sudharshan ,
Could you please send me all of your project to have more information and visibility on the configuration of SPI and DMA so that I can help you?
Thank you.
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.
Eya
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-07-19 02:00 AM
Hello @Sudharshan ,
Please read our recommendations on how to post a thread in this community especially on how to share the code:
I invite you to edit your code and use </> button to paste your code.
Thank you for your understanding
2024-07-19 02:46 AM
Hi @ELABI.1
Thans for the response
Can you please share your STM mail ID
Some of the info we can't share in Forum, but we can be able to share over mail to you
Also, it would be good if we have short call discussion on this either teams meet or google meet
2024-07-19 03:08 AM
Hello @Sudharshan
You can send me your project via private message.
If you need dedicated support and assistance via meetings, you need to contact your FAE or local distributor.
This is not part of our scope in the community.
Thank you for your understanding.
Eya
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-07-19 03:11 AM
2024-07-19 04:00 AM
Hello @Sudharshan
you can look for a local contact from Contacts - STMicroelectronics.
Thank you.
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.