STM32F4 discovery board and arduino SPI problem
- November 5, 2020
- 2 replies
- 3787 views
Hello,
I'm trying to establish SPI communication between STM32F4 discovery board with STM32F407 MCU and an Arduino uno. The arduino acts as a master and I'm using it to interface my board(which acts as slave) with the PC since I like arduino uno's serial terminal(and because the discovery board does not have virtual terminal enabled by default I have to do some hardware stuff in order to get it to work).
What I' trying to do now is send a byte from the arduino's serial terminal to the arduino via USART and then to the discovery board via SPI and toggle a led in the receive completed callback function to ensure the communication works smoothly.
However I have the following problem: The callback does not get called everytime I send something from the arduino it gets called only some times. My first thought was that maybe the arduino sends data too fast for the board to read but I don't think this is the case. My board's SPI baudrate should be APB1/2 = 21Mhz and I ensured in the arduino code that the SPI on that side is configured to the same baudrate.
I generated the STM's code with CubeMX. I'm using SPI1 as peripheral.
The settings are like this:
Frame format: Motorola
Data Size: 8 bits
First Bit: MSB First
Clock Polarity: Low
Clock Phase: 1 edge(CPOL = 0, CPHA = 0)
CRC: Disabled
NSS Signal Type: Input Hardware
I doubled checked that the same settings have been configured in arduino. Still the problem persists. The byte from the arduino to my board sent via the SPI seems to not arrive every time(because the HAL_SPI_RxCpltCallback function does not get called all the time).
Please help me understand what could cause this trouble and how can I work towards fixing it. Thank you!
I have uploaded the stm_code and the arduino code in case that is helpful.