cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with SPI Clock on STM32L562VE MCU with TZEN = 0 Configuration

Giridhara_Datta_G
Associate III

Hello STM32 community,

I'm facing an issue with my STM32L562VE MCU where I'm not receiving SPI clock signals whenever I attempt to transmit or receive data.

Here are the specifics of my setup:

MCU: STM32L562VE
SPI Mode: 0
Data Word Length: 8 bits
Main Clock Frequency: 80MHz
SPI Clock Frequency (after prescaler of 2): 40MHz
MCU is connected to two crystals:
LSE (Low-Speed External) crystal: 32kHz
HSE (High-Speed External) crystal: 48MHz
Clock Source Used: MSI only (despite having LSE and HSE crystals)
I've also uploaded the .ico file and other related files for reference.

Despite these configurations, I'm not receiving the expected SPI clock signals. I've checked my connections and configurations, but I haven't been able to identify the root cause of the issue.

Has anyone in the community encountered a similar problem with SPI clock signals on the STM32L562VE MCU? Any insights, suggestions, or solutions would be greatly appreciated.

Thank you for your assistance.

Best regards,
Giridhara Datta G

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

For a 40 MHz signal, set the speed to VERY_HIGH, or whatever the max setting is for your chip. This can be done in the SPI tab and possibly the GPIO tab as well.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
Giridhara_Datta_G
Associate III

The code I'm running is:

 

int main(void)
{
  /* USER CODE BEGIN 1 */

  /* 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_ICACHE_Init();
  MX_SPI1_Init();
  MX_SPI2_Init();
  MX_TIM15_Init();
  MX_UART4_Init();
  /* USER CODE BEGIN 2 */
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
	  uint8_t txData[4] = {0};
	  static uint8_t rxData[4];
	  HAL_GPIO_WritePin(SPI2_CS_GPIO_Port, SPI2_CS_Pin, 0);
	  HAL_SPI_TransmitReceive(&hspi2, txData, rxData, 4, 100);
	  HAL_GPIO_WritePin(SPI2_CS_GPIO_Port, SPI2_CS_Pin, 1);
  }
  /* USER CODE END 3 */
}

 

This was just to verify the SPI functionality. But when I observe the SPI Clk pin I'm not getting any clock signal.
The same code with the changed SPI handler (SPI 1 & SPI 3 both are working) in STM32L432KC nucleo board is working fine and I'm getting clock signal properly.

  1.  These are the signals I'm getting for STM32L562VET6 :
  2. 0 - MOSI, 1 - MISO, 2 - SCLK, 3 - CS0 - MOSI, 1 - MISO, 2 - SCLK, 3 - CS

     

     These are the signals I'm getting for STM32L432KC : 

    0 - MOSI, 1 - MISO, 2 - SCLK, 3 - CS0 - MOSI, 1 - MISO, 2 - SCLK, 3 - CS Zoomed to view Clock signalZoomed to view Clock signal

     

     

    The code used both the MCUs are same with corresponding SPI handlers.

likhitajayakanth
Associate

I've been facing the same issue

TDK
Guru

> GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

For a 40 MHz signal, set the speed to VERY_HIGH, or whatever the max setting is for your chip. This can be done in the SPI tab and possibly the GPIO tab as well.

If you feel a post has answered your question, please click "Accept as Solution".