On board SPI to SPI in STM32F207ZGT6
#include "main.h"
SPI_HandleTypeDef hspi1;
SPI_HandleTypeDef hspi3;
UART_HandleTypeDef huart3;
/* USER CODE BEGIN PV */
char spi_data_tx[1]={'1'};
char spi_data_rx[1]={'0'};
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_SPI1_Init(void);
static void MX_SPI3_Init(void);
static void MX_USART3_UART_Init(void);
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI1_Init();
MX_SPI3_Init();
MX_USART3_UART_Init();
/* USER CODE BEGIN 2 */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_6, GPIO_PIN_SET); //CS ->High
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
spi_data_rx[0]='0';
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_6, GPIO_PIN_RESET); //CS -> Low
HAL_SPI_Transmit(&hspi1, spi_data_tx, 1,10);
HAL_SPI_Receive(&hspi3, &spi_data_rx,1,10);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_6, GPIO_PIN_SET); //CS ->High
HAL_UART_Transmit(&huart3, spi_data_rx,1,10);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
The below code is my logic for onboard_SPI_to_SPI Communication. It is not working Properly.
If there is any mistakes, please let me know!
thank you
