2024-03-05 09:55 PM
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
Solved! Go to Solution.
2024-03-06 12:54 PM
> 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.
2024-03-06 01:12 AM - edited 2024-03-06 01:14 AM
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.
2024-03-06 01:29 AM - edited 2024-03-06 01:44 AM
These are the signals I'm getting for STM32L432KC :
The code used both the MCUs are same with corresponding SPI handlers.
2024-03-06 08:53 AM - edited 2024-03-06 10:04 AM
I've been facing the same issue
2024-03-06 12:54 PM
> 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.