Skip to main content
Graduate II
March 1, 2024
Solved

HSE crystal dead

  • March 1, 2024
  • 10 replies
  • 5481 views

Hello

I am trying to powerup external 8MHZ crystal on STM32F407VET6 MCU but it is completely dead. I run the LED bliking program using HSI, and it is working sucussfully. Boot 0 and Boot1 pins have been PD with 500 ohm. 

 I also run the same code to use HSE on STM4 Discovery board after removing R68, I see HSE on board is working. 

Below are my caclulation

Frequency = 8 Mhz,

Co = 7 pF ( as per datasheet)

CL= 10 pF ( as per datasheet, used 20pF CL1 and CL2) 

ESR = 100  ohm ( as per data sheet)

After calculation gmcrit comes..

gmcrit = .287 

gm =  5 ( from ST data sheet)

gain margin = 5/.287 = 17    

so gain margin > 5 condition is met. 

I also changed Rext  to 0, 100, 200, 500 , 1000 ohm. HSE is dead. 

PCB design seems ok , and I assume for now no issue with PCB design.

I have gone through AN2867, but not sure what point I am missing.

Kindly suggest where could be the fault.  I eliminate software issue as same code is making HSE work on Discovery board.

Nico3_0-1709283992146.png

 

 

 

 

 

    This topic has been closed for replies.
    Best answer by Peter BENSCH

    ...and do it step by step:

    1. remove the crystal from the DISCOVERY
    2. check that the programme is not running on the DISCOVERY, which is correct without the crystal
    3. place the other crystal on the DISCOVERY and finally
    4. check that the programme (and therefore the crystal) is running

    10 replies

    Graduate
    March 1, 2024

    Crystal can be defective or its parameters are out of MCU acceptability. Try different crystal (from Nucleo board). You can try also 1Mohm rezistor paralel to crystal.

    Nico3Author
    Graduate II
    March 1, 2024

    I am using one from Nucleo F091RC board. I aso connected 1Mohm parrallel to crystal. But no success.

    Technical Moderator
    March 1, 2024

     

    Your calculation is generally correct, and HSE should work on the lab bench, although the values for CL1 and CL2 are a little too large. You should also consider the board and pin capacitance and dimension CL1 and CL2 to 12...15pF, for example.

    However, you have only shown a section of the schematics:

    • Does VDDA have the same potential as VDD?
    • What potential does VREF+ see?
    • Are all VSS connected to GND and all VDD connected to the supply voltage?
    • Do you have the 2.2µF capacitors on the VCAP pins?
    • Why don't you have a 100nF capacitor on NRST?
    • BOOT1 does not have to be at 0, but this does not matter if BOOT0=0 (see AN2606, pattern 1)

    Regards
    /Peter

    Nico3Author
    Graduate II
    March 1, 2024

    Please find answer 

    • Does VDDA have the same potential as VDD?

    VDDA is tied to VDD

    • What potential does VREF+ see?  VREF+ is also tied to VDD
    • Are all VSS connected to GND and all VDD connected to the supply voltage?
    • Yes  all VSS connected to GND and all VDD to supply voltage
    • Do you have the 2.2µF capacitors on the VCAP pins?
    • Yes, 2.2uf connected to VCAP1 and VACP2,  I see voltage there around 1.2 V,    VDD is 3.3V
    • Why don't you have a 100nF capacitor on NRST?
    • 100 nF with GND is connected to NRST , NSRT is also PU by 3.3V.
    Technical Moderator
    March 1, 2024

    I have not yet seen an application with STM32 where the 1M was necessary parallel to the Crystal.

    Are you absolutely sure that the STM32F407VET6 is positioned correctly and not rotated by ±90° or 180°?

    Please also check that CL1 and CL2 are not defective and perhaps have a short to GND. To be on the safe side, you can also replace them again.

    What does your layout around the HSE and its connection to the STM32 look like?

    Nico3Author
    Graduate II
    March 1, 2024

    uC oritentation is correct as LED blinking program is working using HSI. I changed CL1 and CL2 but same situation. I am yet to try with lower CL values.

    Pls find the pcb layout.  

    Nico3_0-1709293704874.png

     

    Technical Moderator
    March 1, 2024

    Well, the layout is an example of how not to build it:

    • crystal too far away from the STM32
    • signal(s) underneath the crystal
    • GND around the crystal completely unsuitable:
      • no guard ring around Y1, no separate GND area underneath (see AN2867, section 7.1 and 7.2)
      • No separate and direct GND connection to pin 10 of the STM32

    BTW: NRST does not require a pull-up as it is already installed (see RM0090, section 6.1.2). Yes, I know that a pull-up can sometimes be found, e.g. with the Blue Pills from Asian suppliers - which is still not correct.

    Finally: are you also 100% sure that the HSE has been activated?
    Not that you accidentally selected a different clock source on the DISCOVERY?

    Nico3Author
    Graduate II
    March 1, 2024

    Thanks very much peter, I will get layout corrected. 

    Anyway on making sure clock source, I am using same code on STM32F4 Disco board with LED connected to PA1 , it works.

    I also see able to see crystal o/p clock on MCO PA8 pin on enabling Master clock output

     

    Configuration used on STM32F4 disco board:

    Nico3_0-1709298055740.png

     

    Graduate
    March 1, 2024

    Try putting a crystal from your board into the Disco board. You will verify its functionality.

    Graduate II
    March 1, 2024

    Show your code that enables the HSE, it doesn't start automatically.

    One the DISCO and NUCLEO boards it typically gets a CMOS clock from the ST-LINK which is started independently of your code

     

    Nico3Author
    Graduate II
    March 1, 2024

    Below is my code

    /* USER CODE BEGIN Header */
    /**
    ******************************************************************************
    * @file : main.c
    * @brief : Main program body
    ******************************************************************************
    * @attention
    *
    * Copyright (c) 2023 STMicroelectronics.
    * All rights reserved.
    *
    * This software is licensed under terms that can be found in the LICENSE file
    * in the root directory of this software component.
    * If no LICENSE file comes with this software, it is provided AS-IS.
    *
    ******************************************************************************
    */
    /* USER CODE END Header */
    /* Includes ------------------------------------------------------------------*/
    #include "main.h"
    
    /* Private includes ----------------------------------------------------------*/
    /* USER CODE BEGIN Includes */
    
    /* USER CODE END Includes */
    
    /* Private typedef -----------------------------------------------------------*/
    /* USER CODE BEGIN PTD */
    
    /* USER CODE END PTD */
    
    /* Private define ------------------------------------------------------------*/
    /* USER CODE BEGIN PD */
    
    /* USER CODE END PD */
    
    /* Private macro -------------------------------------------------------------*/
    /* USER CODE BEGIN PM */
    
    /* USER CODE END PM */
    
    /* Private variables ---------------------------------------------------------*/
    UART_HandleTypeDef huart2;
    
    /* USER CODE BEGIN PV */
    
    /* USER CODE END PV */
    
    /* Private function prototypes -----------------------------------------------*/
    void SystemClock_Config(void);
    static void MX_GPIO_Init(void);
    static void MX_USART2_UART_Init(void);
    /* USER CODE BEGIN PFP */
    
    /* USER CODE END PFP */
    
    /* Private user code ---------------------------------------------------------*/
    /* USER CODE BEGIN 0 */
    
    /* USER CODE END 0 */
    
    /**
     * @brief The application entry point.
     * @retval int
     */
    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_USART2_UART_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 */
    
     HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_1);
     HAL_Delay(1000);
     }
     /* USER CODE END 3 */
    }
    
    /**
     * @brief System Clock Configuration
     * @retval None
     */
    void SystemClock_Config(void) {
     RCC_OscInitTypeDef RCC_OscInitStruct = {0};
     RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
    
     /** Configure the main internal regulator output voltage
     */
     __HAL_RCC_PWR_CLK_ENABLE();
     __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
    
     /** Initializes the RCC Oscillators according to the specified parameters
     * in the RCC_OscInitTypeDef structure.
     */
     RCC_OscInitStruct.OscillatorType =
     RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
     RCC_OscInitStruct.HSEState = RCC_HSE_ON;
     RCC_OscInitStruct.HSIState = RCC_HSI_ON;
     RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
     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_HSE;
     RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
     RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
     RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
    
     if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) {
     Error_Handler();
     }
     HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1);
    }
    
    /**
     * @brief USART2 Initialization Function
     * @PAram None
     * @retval None
     */
    static void MX_USART2_UART_Init(void) {
     /* USER CODE BEGIN USART2_Init 0 */
    
     /* USER CODE END USART2_Init 0 */
    
     /* USER CODE BEGIN USART2_Init 1 */
    
     /* USER CODE END USART2_Init 1 */
     huart2.Instance = USART2;
     huart2.Init.BaudRate = 115200;
     huart2.Init.WordLength = UART_WORDLENGTH_8B;
     huart2.Init.StopBits = UART_STOPBITS_1;
     huart2.Init.Parity = UART_PARITY_NONE;
     huart2.Init.Mode = UART_MODE_TX_RX;
     huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
     huart2.Init.OverSampling = UART_OVERSAMPLING_16;
     if (HAL_UART_Init(&huart2) != HAL_OK) {
     Error_Handler();
     }
     /* USER CODE BEGIN USART2_Init 2 */
    
     /* USER CODE END USART2_Init 2 */
    }
    
    /**
     * @brief GPIO Initialization Function
     * @PAram None
     * @retval None
     */
    static void MX_GPIO_Init(void) {
     GPIO_InitTypeDef GPIO_InitStruct = {0};
     /* USER CODE BEGIN MX_GPIO_Init_1 */
     /* USER CODE END MX_GPIO_Init_1 */
    
     /* GPIO Ports Clock Enable */
     __HAL_RCC_GPIOC_CLK_ENABLE();
     __HAL_RCC_GPIOH_CLK_ENABLE();
     __HAL_RCC_GPIOA_CLK_ENABLE();
     __HAL_RCC_GPIOB_CLK_ENABLE();
     __HAL_RCC_GPIOD_CLK_ENABLE();
    
     /*Configure GPIO pin Output Level */
     HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);
    
     /*Configure GPIO pin Output Level */
     HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);
    
     /*Configure GPIO pin : PDM_OUT_Pin */
     GPIO_InitStruct.Pin = PDM_OUT_Pin;
     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
     GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
     HAL_GPIO_Init(PDM_OUT_GPIO_Port, &GPIO_InitStruct);
    
     /*Configure GPIO pin : PA1 */
     GPIO_InitStruct.Pin = GPIO_PIN_1;
     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
    
     /*Configure GPIO pin : BOOT1_Pin */
     GPIO_InitStruct.Pin = BOOT1_Pin;
     GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     HAL_GPIO_Init(BOOT1_GPIO_Port, &GPIO_InitStruct);
    
     /*Configure GPIO pin : PD14 */
     GPIO_InitStruct.Pin = GPIO_PIN_14;
     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
     HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
    
     /*Configure GPIO pin : PA8 */
     GPIO_InitStruct.Pin = GPIO_PIN_8;
     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
     GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
    
     /* USER CODE BEGIN MX_GPIO_Init_2 */
     /* USER CODE END MX_GPIO_Init_2 */
    }
    
    /* USER CODE BEGIN 4 */
    
    /* USER CODE END 4 */
    
    /**
     * @brief This function is executed in case of error occurrence.
     * @retval None
     */
    void Error_Handler(void) {
     /* USER CODE BEGIN Error_Handler_Debug */
     /* User can add his own implementation to report the HAL error return state */
     __disable_irq();
     while (1) {
     }
     /* USER CODE END Error_Handler_Debug */
    }
    
    #ifdef USE_FULL_ASSERT
    /**
     * @brief Reports the name of the source file and the source line number
     * where the assert_param error has occurred.
     * @PAram file: pointer to the source file name
     * @PAram line: assert_param error line source number
     * @retval None
     */
    void assert_failed(uint8_t *file, uint32_t line) {
     /* USER CODE BEGIN 6 */
     /* User can add his own implementation to report the file name and line
     number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file,
     line) */
     /* USER CODE END 6 */
    }
    #endif /* USE_FULL_ASSERT */
    Technical Moderator
    March 1, 2024

    ...and do it step by step:

    1. remove the crystal from the DISCOVERY
    2. check that the programme is not running on the DISCOVERY, which is correct without the crystal
    3. place the other crystal on the DISCOVERY and finally
    4. check that the programme (and therefore the crystal) is running
    Nico3Author
    Graduate II
    March 2, 2024

    Please note Crystal is working now. 

    1) I used crystal from DISCO board, still same situation.. not working

    2) I used lower CL1 and CL2, still same siutation

    3) I changed MCU , Crystal started working. 

    I am not sure what went wrong during PCBA with old MCU. It was brand new  and visual inspection was saying good soldering.. ESD protection was also followed...

    Anyway finally it is good day today..;)

    Thanks again for taking time...

     

    Graduate II
    March 1, 2024

    @Peter BENSCH wrote:

    • crystal too far away from the STM32
    • signal(s) underneath the crystal
    • GND around the crystal completely unsuitable:
      • no guard ring around Y1, no separate GND area underneath (see AN2867, section 7.1 and 7.2)
      • No separate and direct GND connection to pin 10 of the STM32

     

    I partly disagree to your comments and the AN:

    - The guard ring around the STM-pins on the assembly layer in the AN is so highly unrealistic, or do you still offer packages with a big enough pitch? 

    - Split GNDs might be more dangerous than helpful, also depending what's on the next layers

    - Too far away, really? Alone the THT size of the crystal is a problem then. And with fully packed designs.

    - I only see GND underneath the crystal

     

    I agree that the ground plane should have many more vias - and there's hopefully an internal GND plane directly underneath.

    Anyway, I think it should work with this layout. If not, oh my, is that STM32 oscillator that sensitive!?

    @Nico3 :

    - have you already tried another crystal and other capacitors?

    - what's on the next PCB layers?

    Nico3Author
    Graduate II
    March 1, 2024

    Will try other crystal and capacitor as suggested  earlier also. 

    It  is two layer PCB . Bottom layer mostly ground.

    Nico3_0-1709306635909.png

     

    Graduate II
    March 1, 2024

    two layer PCB

    Any reason for that?

    Almost any design containing anything switching should be made with 4 layers, with a non-split GND plane adjacent to each signal layer.

    Edit: @Peter BENSCH now I see the signal on the bottom layer beneath the crystal. I was hoping for a GND plane underneath...

    Nico3Author
    Graduate II
    March 3, 2024

    @LCE 

    It may sound crazy, but just to keep lower costs and complexity.. we are keeping only two layer

    Graduate II
    March 4, 2024

    As long as it works and it passes the EMI CE / FCC tests, 2 layers are fine. :D

    Graduate II
    March 4, 2024

    @Peter BENSCH thanks for the reply!
    So the LSE is usually the sensitive part, and I understand that for power saving reasons it's high impedance -> low power - but more sensitive

    All in all, it is therefore highly recommended to ensure a super clean layout for the crystals ...

    Definitely! Sometimes a little hard for the beginners, but my experience with other ICs is that there were never any problems - even with my first "bad" PCB layouts 25 years ago. ;)

    Just saying that the AN sounds as if 3 mm too far away and everything breaks down.

    Looking over the HSE / user problems here, most of the time it was a broken component or the caps were far from the recommended values - or not mounted at all.