AnsweredAssumed Answered

STM32L051C6T6 MSI clock range problem

Question asked by matuska.tomasz on Jun 2, 2015
Latest reply on Jun 12, 2015 by matuska.tomasz
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 65.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 131.072 kHz it works fine, but debug still get stucked at the same line as before. When I changed MSI clock speed to 262.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 CubeMX

void SystemClock_Config(void)
  RCC_OscInitTypeDef RCC_OscInitStruct;
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
  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;
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
  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);