2018-07-10 02:14 AM
Hello, Help me please. I configuration STM32L452RET6 in the CUBEMX, how on the pictures. Then I build project in the Attolic and go to debuger and then when MCU is starting work, it go in the HardFault_Handler(void) through 1-5 seconds. Why? I can't find problem. Maybe anyone know?
Crystal clock is Abracon LLC ABM9- 8.000MHZ-10-D-1U-T.
/** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** *//* Includes ------------------------------------------------------------------*/&sharpinclude 'main.h'&sharpinclude 'stm32l4xx_hal.h'/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*//* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);static void MX_GPIO_Init(void);/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*//* USER CODE END PFP */
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point. * * @retval None */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(); /* USER CODE BEGIN 2 *//* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */ while (1) { HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_12); HAL_Delay(300); /* USER CODE END WHILE *//* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */}
/**
* @brief System Clock Configuration * @retval None */void SystemClock_Config(void){RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;/**Initializes the CPU, AHB and APB busses clocks
*/ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }/**Initializes the CPU, AHB and APB busses 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_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
{ _Error_Handler(__FILE__, __LINE__); }/**Enables the Clock Security System
*/ HAL_RCC_EnableCSS();/**Configure the main internal regulator output voltage
*/ if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }/**Configure the Systick interrupt time
*/ HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);/**Configure the Systick
*/ HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);}/** Configure pins as
* Analog * Input * Output * EVENT_OUT * EXTI*/static void MX_GPIO_Init(void){GPIO_InitTypeDef GPIO_InitStruct;
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE();/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);/*Configure GPIO pin : PA12 */
GPIO_InitStruct.Pin = GPIO_PIN_12; 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);}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
* @brief Period elapsed callback in non blocking mode * @note This function is called when TIM2 interrupt took place, inside * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment * a global variable 'uwTick' used as application time base. * @param htim : TIM handle * @retval None */void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){ /* USER CODE BEGIN Callback 0 *//* USER CODE END Callback 0 */
if (htim->Instance == TIM2) { HAL_IncTick(); } /* USER CODE BEGIN Callback 1 *//* USER CODE END Callback 1 */
}/**
* @brief This function is executed in case of error occurrence. * @param file: The file name as string. * @param line: The line in file as a number. * @retval None */void _Error_Handler(char *file, int line){ /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ while(1) { } /* USER CODE END Error_Handler_Debug */}&sharpifdef 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, tex: printf('Wrong parameters value: file %s on line %d\r\n', file, line) */ /* USER CODE END 6 */}&sharpendif /* USE_FULL_ASSERT *//**
* @} *//**
* @} *//************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#stm32l452 #stm32l4 #no-working-hse-stm32l42018-07-10 02:55 AM
Perhaps your Flash settings (wait states) are not correct ?
I would try with a reduced core clock.
2018-07-10 04:53 AM
Look at the code that is actually faulting. Ideally outputting diagnostic information to USART or SWV
Try also clearing the structures when allocating from the stack
RCC_OscInitTypeDef RCC_OscInitStruct= {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};2018-07-10 04:58 AM
Isn't this one of the known CubeMX bugs ('does not set one of the PLL parameters')?
JW
[EDIT]
2018-07-10 05:10 AM
Sorry, If I am reducing core clock, the problem save
2018-07-10 05:23 AM
And please say me, How change Flash settings on the truth?
2018-07-10 06:20 AM
Not sure what you mean, I guess there is something lost in Google-translation.
If the problem persists even without PLL, it looks like a runtime problem (bug).
Perhaps a stack overflow.
You could try to debug the issue, or add telemetry (debug output) to your code.
2018-07-10 06:51 AM
Where are the other posts gone ????????????
2018-07-10 07:00 AM
If I connect System Clock Mux to PLLCLK, no problem. But if connecting to HSE, problem is save.
2018-07-10 10:38 AM
If you are clocking at 8 MHz I don't think the flash is an issue.
Device should start/run from 4 MHz MSI
You might want to enable HSE and feed to MCO (PA8) pin, and scope it there.
For oscillator source, consider HSE BYPASS mode.
Check HSE coming ready.
Check also define for HSE_VALUE in stm32xxxx_hal_conf.h
There have been issues with PLLM value being set up properly, but again, should drive directly from HSE