SPI value doesn't update in STM32F746
Hello, I'm using a STEVAL-PLC001V1 card. It is based on a STM32F746ZGT7 that is linked to a CLT01-38SQ7 for inputs and ISO8200AQ for outputs, using SPI.
I try to read datas sent through SPI by the CLT01-38SQ7 and then send it back to the ISO8200AQ.
My board is configured as follow :
- SPI2_MOSI : PC1
- SPI2_MISO : PC2
- SPI2_SCK : PB13
- GPIO_Output : PB12
- GPIO_Input : PB9
I have the following code (only my custom code):
uint8_t inputData;
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* MCU Configuration--------------------------------------------------------*/
/* 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_DMA_Init();
MX_RTC_Init();
MX_SPI2_Init();
MX_DMA2D_Init();
/* USER CODE BEGIN 2 */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); // Sélection du module d'entrée
HAL_SPI_Receive(&hspi2, &inputData, sizeof(inputData), HAL_MAX_DELAY);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); // Sélection du module de sortie
HAL_SPI_Transmit(&hspi2, &inputData, sizeof(inputData), HAL_MAX_DELAY);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);
HAL_Delay(1000);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
I receive datas through the SPI only once, and if I want to update it I have to unplug power source and plug it again.
I may have not totally understood how SPI works yet, is there something that I am doing wrong ?
