2023-09-26 02:16 AM
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);
}
2023-09-28 03:10 AM
A minimal loopdelay-based blinky (i.e. no clock setup, running from default internal clock) works?
JW
2023-09-28 03:35 AM
I just had a look at your clock settings and compared to an old Nucleo G431 project.
- why PWR_REGULATOR_VOLTAGE_SCALE1_BOOST ?
- your PLL multiplier N = 40 might be too high, assuming your crystal is > 8 MHz, so what's the X1 frequency?
2023-09-28 03:44 AM
And please tell us the exact type of X1.
2023-09-28 06:09 AM
I believe the clock configuration is ok. I set it up in CubeIDE. Usually it will have a hissy fit if something is incorrect.
Exact Resonator is a Murate CSTNE8 8 MHz Ceramic Resonator. I have used it on many other ST devices without issue.
2023-09-28 06:11 AM
CSTNE8M00GH5C000
2023-09-28 06:22 AM
I will try that if I get it going again. Is it possible the Firmware.My code could kill the IC? I have not experienced this before, and the only feasible thing I could think of is to perpetually write to the Program memory...I do not believe this happening though as the program would stutter during page writes.
2023-09-28 06:34 AM
> All 4 controllers now cannot be programmed, and 1 is a complete short circuit.
It's not typical for chips to fail even if power is slightly suboptimal. Invalid power is the most likely cause of a fried controller. Could also be from feeding high voltages into GPIO pins, but your circuit seems benign.
Hard to verify the correctness of the EPAD soldering, so we're going to have to take your word there. That's always something to look into.
You never answered the question about bypass and bulk capacitors. Are they present on the board? How exactly is this being powered? What is generating the 3V3?
2023-09-28 06:39 AM
A ceramic resonator, interesting. That really much better than the HSI?
Anyway, with 8 MHz that's seemingly not the problem then.
2023-09-28 07:13 AM
Is your DRDY_ADC at PA0 an EXTI0? If so, you may be taking that interrupt before your code is ready to handle it (e.g., supporting data structures not yet initialized). I always go through Core/Src/gpio.c and #if 0 all the HAL_NVIC_EnableIRQ() calls and only do those when I know my code is actually ready/initialized correctly.
2023-09-28 08:45 AM
Here is my PSU from 12V to 3V3. 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?