Question
STM32L051C6T6 MSI clock range problem
Posted on June 02, 2015 at 00:55
Hello!
I have a problem with MSI clock configuration on STM32L051C6T6. I wanted to test my device with this microcontroller and I generated a simple code for Keil MDK v5 (LED blinking and USART transmission) using a CubeMX tool. CubeMX generated SystemClock_Config function, that should set a MSI clock speed (range) at 536 kHz (listed below). But when I run the program, microcontroller does not work and everything seems to be dead. When I debugged the code, it get stucked at the macro that writes the value of the clock speed to the registers and Keil showed error Internal Communication Error. When I changed MSI clock speed to 072 kHz it works fine, but debug still get stucked at the same line as before. When I changed MSI clock speed to 144 kHz, code and debug work just fine. I double checked the code generated by CubeMX with all documents from ST website. Can somebody please explain me why the lower speeds do not work? Maybe I did something wrong? Please help me with my problem. Function generated by CubeMXvoid SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
__PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = 0;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_0;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
__SYSCFG_CLK_ENABLE();
}
#stm32l #clock-configuration #msi