1

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.)

enter image description here

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.

Static
  • 11
  • 2
  • The quartz type does not describe which exact model you are using. Mainly the load capacitance rating of the model you are using is important to know if the 9pF capacitors are correctly calculated. Just to be sure, if the datasheet says Cl is 9pF, it does not mean that it needs two 9pF capacitors. And most likely you can route the LSE frequency out to MCO pin to be able to measure a logic level signal, as connecting a scope probe to crystal pins is likely to stop it. – Justme Oct 15 '21 at 09:46
  • That capacitance spec ("9pF") is the total load capacitance seen by the crystal, not the value of each capacitor you use on each pin. You need to at least estimate the parasitic capacitance of your PCB, add in the capacitance of the micro's pins, and also remember that from the crystal's point of view 2 caps you add (one on each pin) are *in series* with each other. – brhans Oct 15 '21 at 12:38
  • The crystal is in the list of supported crystals. Double check the LSE drive strength setting if it is correct for the crystal. Failing that, the capacitors may be incorrectly calculated (it assumes there is 4.5pF of stray capacitance) or you might need a crystal with lower load capacitance rating to achieve higher gain margin. – Justme Oct 15 '21 at 12:40
  • You call it a 32768 kHz crystal, but are you sure? 32.768 kHz is common, but 32768 kHz is not. – Hearth Oct 15 '21 at 18:34
  • What does your system clock set-up code look like? – Lundin Oct 18 '21 at 09:13
  • So it works after resetting your micro? Does it work when you power it with a lab supply instead of USB? – markus-nm Oct 18 '21 at 16:18
  • In case you are relying on autogenerated code, someone had a similar problem [here](https://community.st.com/s/question/0D50X00009Xke6N/problem-about-lse-clock-of-stm32l431). There it was because of a bug in the bloatware generator. According to that answer `RCC_OSCILLATORTYPE_MSI` shouldn't be there. In general I'd strongly recommend the friendly manual over autogenerated code. – Lundin Oct 19 '21 at 06:18

0 Answers0