cancel
Showing results for 
Search instead for 
Did you mean: 

HSE crystal dead

Nico3
Senior

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

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

...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
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

20 REPLIES 20
ONadr.1
Senior III

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.

Peter BENSCH
ST Employee

 

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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.

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

Peter BENSCH
ST Employee

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?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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

 

Peter BENSCH
ST Employee

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?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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 */