Skip to main content
Dawid Kozub
Associate II
Oct 3, 2017 11:32 AM UTC
Question

STM32F030 was reconfigured by himself - help

Posted on October 03, 2017 at 13:32

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

    This topic has been closed for replies.

    6 replies

    Tesla DeLorean
    Guru
    Oct 3, 2017 12:51 PM UTC
    Posted on October 03, 2017 at 14:51

    >>Why MCU was reconfigured by himself?

    I'd be surprised if it were by mag1c

    HSE failed? Entered SLEEP?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Dawid Kozub
    Associate II
    Oct 3, 2017 6:25 PM UTC
    Posted on October 03, 2017 at 20:25

    HSE is ok. Reset device solved problem. Since 8 hours is everything ok. I am waiting for the same situation...

    I am not using SLEEP...

    Magic will be the best answer this issue... Because I have no idea, how it is possible..

    P.S.

    Maybe if this occurs, I shoud check something else ?

    waclawek.jan
    Super User
    Oct 3, 2017 11:13 PM UTC
    Posted on October 03, 2017 at 23:13

    Boot pin(s)?

    JW

    Dawid Kozub
    Associate II
    Oct 4, 2017 6:45 AM UTC
    Posted on October 04, 2017 at 08:45

    This MCU has only one boot pin (pin 60) - BOOT0 which is connected to ground via 100k resistor

    waclawek.jan
    Super User
    Oct 4, 2017 2:18 PM UTC
    Posted on October 04, 2017 at 14:18

    Try pull down harder - 1k, or if you don't ever use it, short.

    JW

    Dawid Kozub
    Associate II
    Oct 4, 2017 2:32 PM UTC
    Posted on October 04, 2017 at 16:32

    Thank You waclawek.jan for advice. I will try this if this occur...