cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 Reset Issue

Rob Ashworth
Senior

I am having some strange power up (I think) issue with my STM32G431 controller.  Sometimes it runs for a second or two, sometimes nothing.  It will usually not connect via the SWDIO pins so it is difficult to step through in debug to see where the problem is.  I'm suspecting a problem with the clock configuration, SWDIO pins not defaulting to their proper state, or Reset pin problem.  None of which I can put my finger on.  I am used to STM32F4, H7, this is the first time I have used the G4, so willing to accept the problem is on my side!  Any help or pointer appreciated.  I use CubeIDE to configure the clock and generate all of the initialisation code, via the .ioc file. 

 

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  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 = RCC_PLLM_DIV1;
  RCC_OscInitStruct.PLL.PLLN = 40;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV8;
  RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses 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_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
  {
    Error_Handler();
  }
  HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1);
}

STM32G4 Schematic.jpg

24 REPLIES 24

Ceramic resonator is good for 0.1% clock timing which I need for CANbus.  I usually assume Internal RC clock is only good for 1% for full temperature range, unless anyone else has different experience?

Yes it is into EXTI0.  If I get it running again, I will disable everything other than CANbus which I need to see if is failed or not.  I like to fit a Blinky LED, but space is so tight!

> Admittedly I do not have any 100nF Caps on there, as I tend to find them superfluous. Is that enough to upset thing that I'm seeing the issue Is have?

That's what my money is on.

Have you looked at 3V3 during startup on an oscilloscope? Might see a spike that would explain things. No way it's rock solid. A DC-DC converter and no decoupling or bulk caps (beyond 2x22uF) certainly goes against hardware recommendations.

I understand they're inconvenient, but if they weren't necessary, they wouldn't be recommended. You can get away with using less, but probably not none.

TDK_0-1695917745177.png

If you could replace that with an LDO (at least temporarily), might also be worth checking. LDO shouldn't be as prone to spikes.

If you feel a post has answered your question, please click "Accept as Solution".

I admit it does look like some sort of PSU issue.  I'm on the 2nd design and changed my DC-DC to this one which I have used lots in the past.  I have scoped it during power up, and all the time whilst monitoring the failure, and it seems to be rock solid - no overshoots etc.  The only time it struggled was when the G4 decided to go short circuit.  I will mount the recommended 100nF and perhaps power form and external PSU as you suggest.  May go quiet for a few days whilst I re-build.

LCE
Principal

Unless it breaks the specs of the power source, there cannot be enough capacitors, for stability, noise, EMI, ...

Come on, a controller powering up with 160 MHz, that might be enough to get a supply spike to reset.