I use a STM32L073 VBT6 LQFP100 with a CC7V-T1A 32.768 kHz crystal as input for a timer. The crystal is connected to two 9pf capacitors for ground, as specified in the manual. (See image.)
On the board, I use USART for communication with a PC or another device. When I plug in the cable connecting the board and the PC and powering the chip, the crystal does not work. I have to reset the STM32L073 to make the crystal work.
The crystal is used for the LSE on the timer I use for the timings in my code. When the crystal does not work, the timer does not start and is always 0. Even if the crystal works, I can not see the oscillation on my oscilloscope, because when I touch the crystal with my oscillator probe, the crystal stops working, I see a flat line and the code stops working.
To sum it up:
- A board with STM32L073 VBT6 LQFP100 and a CC7V-T1A 32768 kHz crystal
- Two 9pf capacitors for ground
- Plugging in the cable with connection and 5V, the crystal does not start
- Resetting the chip make the application work.
I have confirmed that I have the probe set to 1/10 and it still stops the crystal. When I measure the driver side, it does not stop, but I still see a flat line, which is what I am supposed to see on this side. I suppose.
I use the STM32 CUBE IDE. I have activated the LSE in IDE settings, it wouldn't work otherwise, even after the reset.
@Justme - The 9pf were written in my company's documents, as well as the name of the crystal. The full name seems to be: "CC7V-T1A-32.768kHz-9pF-20PPM-TA-QC". I have already routed the LSE to the MCO pin and I can verify that it works at the expected frequency.
@Hearth - Yes, 32.768kHz
@Lundin
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Configure LSE Drive Capability
*/
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = 0;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
{
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USART2
|RCC_PERIPHCLK_LPTIM1;
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
PeriphClkInit.LptimClockSelection = RCC_LPTIM1CLKSOURCE_LSE;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_LSE, RCC_MCODIV_1);
}
I found the solution: Setting the 'LSE Drive Capability' to high AND setting the 'LSE Startup Timeout Value' to ~10000 fixed the issue. It was a software problem after all.