AnsweredAssumed Answered

STM32F030 was reconfigured by himself - help

Question asked by Dawid Kozub on Oct 3, 2017
Latest reply on Oct 4, 2017 by Dawid Kozub

Hi community,

I need help again. I have a problem with my stm32f030RCT6 program. Yesterday I programmed this MCU and today morning a saw problem. Problem is with reconfiguring rcc settings. MCU was programmed with PLL = 6x and HSE = on:

/** System Clock Configuration
*/
void SystemClock_Config(void)
{

RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInit;

/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI14
|RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
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_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}

/**Enables the Clock Security System
*/
HAL_RCC_EnableCSS();

/**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, 3, 0);
}

 

today morning, when problem occured i debug MCU by STMstudio and I readed values from registers 0x40021000 = 0x86AFB and 0x40021004 = 0x110000

From these registers I know about reconfiguration rcc.
0x40021000 = 0x86AFB -> It means HSEON(bit 16) is reset, HSERDY(bit 17) is reset, PLLON(bit 24) is reset and PLLRDY(bit 25) is reset too
0x40021004 = 0x110000 -> It means SW(bits 1 - 2) are reset and SWS(bits 3 - 4) are reset too

After reset MCU everything is correct: 0x40021000 = 0x30B6AFB and 0x40021004 = 0x11000A

Why MCU was reconfigured by himself?

 

Please Help,

   Dawid

Outcomes