SPI communication between two Nucleo G431-KB boards not working
I'm getting introduced to the STM32 environment and I have been trying to use SPI protocol to send messages between these two boards. My setup is as follows:
And in the CubeIDE both boards have this setup, with the difference that the master board has the selection of Full duplex master in SPI and the slave Full duplex slave. The clocks are configured the same way in both boards and I believe I'm not leaving anything.
The master code is the following:
#include "main.h"
#include <stdio.h>
SPI_HandleTypeDef hspi1;
UART_HandleTypeDef huart2;
uint8_t data_rx[1];
uint8_t data_tx[1];
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void);
static void MX_SPI1_Init(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_SPI1_Init();
while (1)
{
data_tx[0] = 3;
HAL_SPI_Transmit(&hspi1, data_tx, sizeof(data_tx), 5000);
}
}The slave code is the following:
#include "main.h"
#include <stdio.h>
SPI_HandleTypeDef hspi1;
UART_HandleTypeDef huart2;
uint8_t data_rx[1];
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void);
static void MX_SPI1_Init(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_SPI1_Init();
while (1)
{
HAL_SPI_Receive(&hspi1, data_rx, sizeof(data_rx),5000);
}
}I'm trying to make it as simple as possible but with these codes and the setup I have detailed before I'm not getting anything at data_rx. I don't know what is wrong as there is not much to see.
Any recommendations to use SPI protocol in this context will be appreciated, thank you.
