2023-09-28 02:24 AM - edited 2023-09-28 03:35 AM
Hi all, I have a problem with a new version of an existing PCB using the STM32F334C8T6 microcontroller.
Known working code is loaded onto the new PCB, power is applied and the MCU starts up the clock and then seems to sit idle. If the NRST pin is then driven low and released the MCU starts up and begins operating normally. Holding NRST low on power up and then releasing it after a duration does not work, the MCU must attempt to start up and fail first. NRST is connected to a 10kΩ to +3V3 and a 100nF to 0V. BOOT0 is connected to a 10kΩ to 0V.
The signals here (top to bottom) are:
old PCB +3V3
old PCB NRST
new PCB +3V3
new PCB NRST
While both boards were powered at the same time the new board has an additional SMPS stage which adds a small delay to the rise of the +3V3 rail.
The signals here (top to bottom) are:
old PCB NRST
old PCB 8.000MHz crystal
new PCB NRST
new PCB 8.000MHz crystal
I've gone through a couple of stages of being suspicious of the clock as it gets enabled by the code, but then the code seems to stop/stall. However the scope traces don't show any significant problems. I've also compared the clock signal after the reset with the MCU running code and it looks identical to the above scope trace where the MCU is stalled.
The new PCB does have a different 8.000MHz crystal so I may have got the load capacitors wrong. The new board is using this crystal from JLC with 2x 22pF 0402 C0G load capacitors. Is this correct? Should I be using a different value?
There are other minor differences between the two boards, but nothing that would suggest this issue. e.g. some pins no longer have a 1kΩ resistor linking them even though one pin was never enabled/driven in the code.
I'm running out of hair to tear out so welcome any suggestions of what the issue might be or further debugging steps. Thanks!
2023-10-03 01:56 AM
I thought I'd managed to narrow the problem down to these lines of code:
InitPinOut( DRV_SLEEP_N );
InitPinOut( DRV_RESET );
//SPI
InitPinOut( DRV_SPI_MOSI );
InitPinIn( DRV_SPI_MISO, GPIO_PULLUP ); //TODO check DRV spec
InitPinOut( DRV_SPI_CS );
InitPinOut( DRV_SPI_SCK );
spi.format(16, 0); // 16 bit, mode 0
spi.frequency(100000);
//Inputs
InitPinIn( DRV_FAULT, GPIO_PULLUP); //TODO pullup needed??
InitPinIn( DRV_STALL_N, GPIO_PULLUP);
However none of these seem likely to cause the issue I'm seeing where the MCU seems to reset and then lock up.
I loaded the original firmware on again just to confirm I'm still seeing the issue and it worked. The MCU booted up from power up, ran the code and operates exactly as it should. I have a second board that also exhibited this issue so now my debugging has moved over to this second board. Having the problem magically fix itself worries me greatly.
2023-10-03 06:11 AM
2023-10-04 12:21 AM - edited 2023-10-04 02:31 AM
> ... Having the problem magically fix itself worries me greatly.
But haven't you played with the crystal and the caps? Or did you put it back into the original state?
Edit: maybe the originally assembled crystal caps were not what they should be?
2023-10-26 01:57 AM
Hi LCE and others,
You're right! So far I've changed the crystal caps on 5x boards to 6.8pF, 4x of these boards now start up pretty reliably with the 5th still having the issue. It does still occasionally happen on the 4x 'working' boards. So I guess my next question is, how do I measure 'good' for crystal capacitors?
I've gotten the updated value of 6pF from this formula: C1 = C2 = 2 * (CLoad – Cstray) from here: https://microchip.my.site.com/s/article/Calculating-crystal-load-capacitor. The JLC/LCSC part listing says CLoad = 8pF, the consensus seems to be that Cstray is usually around 5pF so I calculate 6pF, and the closest value is 6.8pF. However this is still giving me spotty start up issues, especially when cold (like ~5°C)
Thanks!
2023-10-26 03:28 AM
Show us the relevant portion (i.e. around crystal) of PCB layout.
JW
2023-10-26 04:22 AM
Avoid probing directly hse quartz.
Try a very simple sw based on hsi and not hse to only toggle a gpio.
Be sure of all powering, try to catch with scope very short undervoltage.
Have a look to nrst pin. Try without any capacitor on this pin.
What about option bytes? Try without BROWNOUT reset.
2023-10-26 04:57 AM
Okay, it's a 4 layer, 1.6mm thick FR4 board with 2oz copper per layer PCBA.
Top:
Crystal is a 3225 package, left middle. I tried to route the osc pins as a differential-ish signal. Tried to surround them with GND.
Inner 1:
Pour of GND.
Inner 2:
Pour of +3V3
Bottom:
Mostly a pour of GND with some traces. NRST runs under the crystal, and CONSOLE_TX/CONSOLE_RX/TIMING_PULSE are all unused signals crossing at 90deg under the MCU pins.
I think I've done a pretty good job here and there shouldn't be anything iffy about the layout.
2023-10-26 05:34 AM
That looks good, only one question, what is the signal with the via from +2 pins north of the OSC pin? Just curious, shouldn't matter before start up.
2023-10-26 06:40 AM
That's TIMING_PULSE. As of yet, it's not pulsing, so it's just held high with 10kΩ pullups to +3V3.
2024-06-25 09:03 AM
It's been a while but I am still having issues!
After testing a few PCBs with 6.8pF capacitors I thought this was the fix and ordered another 30x PCBs with 6.8pF capacitors.
5x of these boards do not work, on power up they are non-responsive then once reset they activate and respond.
I decided to brute force the solution a bit:
Board | 4.7pF | 5.6pF | 6.8pF | 8.2pF | 10pF | 12pF | 15pF |
A | Not tested | Not tested | Yes | Yes | Yes-untested | Yes | No |
B | Not tested | Not tested | Yes | Yes | Yes-untested | Yes-untested | Not tested |
C | Not tested | Not tested | Yes | Yes | Yes-untested | Yes | Not tested |
D | Not tested | Not tested | Yes | Yes | Yes-untested | Yes-untested | Not tested |
E | Not tested | Yes | Yes | Yes-untested | Yes-untested | Yes | Not tested |
F | No | Not tested | No | Yes | Yes | No | No |
G | Not tested | Not tested | No | No | No | No | Not tested |
H | Not tested | Not tested | No | No | No | Yes | Not tested |
I | Not tested | Not tested | No | Yes | Not tested | Not tested | Not tested |
That seems to suggest that 8.2pF might be a better capacitor. However I'm worried that the thresholds for these capacitors is that tight. Most of the threads I can read about this seem to suggest that the tolerances should be pretty wide.
Is the low load capacitance (8pF) or the high ESR (<120Ω) the reason why this is being so tricky?