Skip to main content
Jeremy Vance
Associate II
June 8, 2018
Question

Slow Clock at powerup requires reset each time

Posted on June 08, 2018 at 20:57

Hello,

   I'm having an odd time with a board using the STM32F746VGT6 microcontroller that it requires that I reset the board each time that I power it up.  I have several of these and the phenomenon only occurs on about half of the boards.  When it does, it requires shorting the reset pin to ground as I don't have a reset button on this design.  I have checked solder joints of the 8MHz crystal and caps as well as the reset circuit (used from stm32f746 discovery board design).  The code is generated from CUBEMX.  It appears to run about 10 times as slow.  I'm trying to run the main PLL clock output at 192MHz.  Here is my startup code for the clock:

void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct;

RCC_ClkInitTypeDef RCC_ClkInitStruct;

RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;

/**Configure the main internal regulator output voltage

*/

__HAL_RCC_PWR_CLK_ENABLE();

__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

/**Initializes the CPU, AHB and APB busses clocks

*/

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLM = 8;

RCC_OscInitStruct.PLL.PLLN = 384;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

RCC_OscInitStruct.PLL.PLLQ = 8;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

/**Activate the Over-Drive mode

*/

if (HAL_PWREx_EnableOverDrive() != 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_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV4;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART2

| RCC_PERIPHCLK_SAI1 | RCC_PERIPHCLK_I2C1

| RCC_PERIPHCLK_I2C2 | RCC_PERIPHCLK_SDMMC1

| RCC_PERIPHCLK_I2S | RCC_PERIPHCLK_CLK48;

PeriphClkInitStruct.PLLSAI.PLLSAIN = 316;

PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;

PeriphClkInitStruct.PLLSAI.PLLSAIQ = 7;

PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV8;

PeriphClkInitStruct.PLLSAIDivQ = 1;

PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;

PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLLSAI;

PeriphClkInitStruct.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;

PeriphClkInitStruct.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;

PeriphClkInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;

PeriphClkInitStruct.I2c2ClockSelection = RCC_I2C2CLKSOURCE_PCLK1;

PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48SOURCE_PLL;

PeriphClkInitStruct.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_CLK48;

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

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

}

Can someone help me please?

Thanks,

Jeremy

#cpu-clock-frequency #stm32f746
This topic has been closed for replies.

10 replies

john doe
Senior III
June 9, 2018
Posted on June 09, 2018 at 23:51

what do you have HSE_VALUE set to

Jeremy Vance
Associate II
June 9, 2018
Posted on June 09, 2018 at 23:59

I have HSE_VALUE set to 8000000.

I have the HSE timeout set to 2000ms

The System clock is set to 192000000.

On Sat, Jun 9, 2018, 5:52 PM john doe <st-microelectronics@jiveon.com>

Tesla DeLorean
Guru
June 10, 2018
Posted on June 10, 2018 at 04:04

So probably 16 MHz HSI (so 12x slower)

Clear the auto/local variables

RCC_OscInitTypeDef RCC_OscInitStruct = {0};

RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};

Surprised it wouldn't plough into the Error_Handler(), does that return?

Check your actually test the oscillator source __HAL_RCC_GET_PLL_OSCSOURCE()

Check define for HSE_TIMEOUT_VALUE

Check clocking of SysTick

Do you have a USART you can actually report internal status/functionality?

Have you quantified the time to start the HSE using some simple code to enable HSE via RCC, and waiting for HSE RDY. Compare/contrast between working/non-working examples.

Change the caps on oscillator see if that improves situation.

Quantify rise time of supply.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Jeremy Vance
Associate II
June 11, 2018
Posted on June 11, 2018 at 22:25

Thanks Clive for the helpful suggestions.  Here are my findings so far:

I have cleared out the local variables and no help.

The Error Handler has a breakpoint and it never hits.  Error handler is just a while(1) loop as default anyway.

HSE_TIMEOUT_VALUE  = HSE_STARTUP_TIMEOUT = 2000U

I'll check what the OSCSource comes back at.

What is the best way to check SysTick clocking?

I do have an internal UART that communicates with another controller it's status.

Do you have sample code to quantify HSE enabling and HSE ready?  I can't use systick for that because it isn't enabled yet.

I currently have 20pF caps on the 8.00MHz (ABM3B-8.000MHZ-B2-T). These are the same crystals and caps I used on a very stable F407 board so I assumed the same would be appropriate since the signal wire lengths are within 2% between the boards.  Also inline resistor of 220 ohms on one leg of the crystal.

I'll measure the rise time of the supply on my scope and see how long it takes to get up to spec.  The input voltage is a 12V battery and it is being stepped down to 3.3V through two linear regulators.  Shouldn't be long.  I'll post more info soon.

Tesla DeLorean
Guru
June 11, 2018
Posted on June 11, 2018 at 22:39

Ok

Is something precluding you from outputting some diagnostic information so you understand the state of the device?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
T J
Senior III
June 10, 2018
Posted on June 10, 2018 at 09:15

if you have to use a reset chip,

this one works well  2.94V threshold and 1.2S delay.

0690X0000060L8nQAE.png
Jeremy Vance
Associate II
June 11, 2018
Posted on June 11, 2018 at 22:55

Thanks for the suggestion TJ.  I'll work it into the next design as a backup.  It can be unpopulated if I can figure this out otherwise.