2018-05-08 08:39 PM
Hi , I have one of STM32L4R9i-DISCO MB , I try to set system clock 120MHZ(MSI ON & PLL ON) , HCLK 15MHZ.
When MB to running the system clock initial function after then the MB to connect with STM32 ST-Link utility , The utility can't access success to the MB and it had report that the massage as 'Read out protection is activated' .The problem can't recovery to do the hardware reset on the MB,
Only one way to recovery the MB back that is remove the power cable. I use the tool of IAR for debug.
Please help to check below code it anything config is wrong? or anything config is lost?
The below is code for system clock initial function.
void SystemClock_Config(void)
{ RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};RtcHandle.Instance = RTC;
/* Enable voltage range 1 boost mode for frequency above 80 Mhz */ __HAL_RCC_PWR_CLK_ENABLE(); HAL_PWR_EnableBkUpAccess(); HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST); __HAL_RCC_PWR_CLK_DISABLE(); /* Enable MSI Oscillator and activate PLL with MSI as source */ /* (Default MSI Oscillator enabled at system reset remains ON) */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI; RCC_OscInitStruct.MSIState = RCC_MSI_ON; RCC_OscInitStruct.LSEState = RCC_LSE_ON; RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI; RCC_OscInitStruct.PLL.PLLM = 12; RCC_OscInitStruct.PLL.PLLN = 60; RCC_OscInitStruct.PLL.PLLR = 2; RCC_OscInitStruct.PLL.PLLQ = 2; RCC_OscInitStruct.PLL.PLLP = 7; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { while(1); }/* Enable MSI Auto-calibration through LSE */
HAL_RCCEx_EnableMSIPLLMode();/* To avoid undershoot due to maximum frequency, select PLL as system clock source */
/* with AHB prescaler divider 2 as first step */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV8; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { while(1); } }