cancel
Showing results for 
Search instead for 
Did you mean: 

More SPI trouble !

Stoufer
Associate III

Hey Guys - more SPI issues!

I have a new board with minimal connections - basically just SPI to a LCD and four pushbuttons. I created a new STM32 project in STM32cube.

It is using a STM32F451VET6 with clock set to MSI RC 4000kHz

I configured SPI in the IOC to :

Full-duplex Master

Hardware NSS Output Signal

PB0 as SPI1_NSS,   PE13 as SPI1_CLK,   PE14 as SPI1_MISO,    PE15 as SPI_MOSI

with the below parameters : 

Stoufer_0-1694467500960.png

I added only a few lines to the auto-generated code for two variables and the SPI transmits ( below ).

Stepping the program it will send the first byte fine. The next byte sends but the HAL_SPI_Transmit() call hangs forever on this line : 

/* Check the end of the transaction */
if (SPI_EndRxTxTransaction(hspi, Timeout, tickstart) != HAL_OK)
{
hspi->ErrorCode = HAL_SPI_ERROR_FLAG;
}

 

Here is the code from Main.c :

 

int main(void)
{
  /* USER CODE BEGIN 1 */
unsigned char On_Command = 0xAF;
unsigned char Off_Command = 0xAE;
 
  /* USER CODE END 1 */
 
  /* 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_SPI1_Init();
  /* USER CODE BEGIN 2 */
 
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
HAL_SPI_Transmit(&hspi1, (uint8_t *)&Off_Command, 1, 100); // write Set Off command to display
HAL_SPI_Transmit(&hspi1, (uint8_t *)&On_Command, 1, 100); // write Set On command to display
HAL_SPI_Transmit(&hspi1, (uint8_t *)&Off_Command, 1, 100); // write Set Off command to display
 
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Stoufer
Associate III

Resolved!  BOOT0 was left unconnected. Set it as input and tied to GND and everything is workin ggreat!

Thanks!

View solution in original post

4 REPLIES 4
Issamos
Lead II

Hello @Stoufer 

I suggest you to double check your configurations and wiring to maker sure that they are master-slave compatible and that the slave requirements are satisfied (clock,...). Also, you have to update your firmware to the last version to garantie more efficiently. After that, try to change (increase or decrease) the timeout of 100ms that may solve the problem.

NB: is an L4 not F4.

Best regards.

II

you are right ... L451.

At this point I only have the Master sending data and monitoring with a scope.

I have tried increasing the timeout .. have not tried reducing it.

Thanks 

Try to reduce it .

I also advise you to use an oscilloscope to track the signal's variations on reel Time. That may help you answering your questions.

Best regards.

II

Stoufer
Associate III

Resolved!  BOOT0 was left unconnected. Set it as input and tied to GND and everything is workin ggreat!

Thanks!