cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] Can't make HSE oscillator to work (STM32F103C8T6)

andyolivares
Associate II
Posted on October 28, 2014 at 04:11

Hello:

I'm writing in desperation because I've been trying to make an HSE oscillator to work with absolutly no luck.

I little bit of context: a couple of months ago, I wanted to play with an STM32F103C8T6 microcontroller for a project I'm trying to do. At first I designed a simple LQFP48 to DIP48 PCB board to mount the uC to a breadboard. Soldered the chip to the DIP shaped PCB and mounted it to the breadboard. I made a simple LDO power supply circuit (3.3V) in the breadboard, put some 100nF capacitors at VDDs/VSSs pins (of my DIP PCB leads), tied BOOT0 and BOOT1 to ground, put a 8 MHz crystal with a couple of 22pF capacitors to ground (all in the breadboard) and it all worked like a charm. I could program the uC with my STLinkV2 with no problems. Just to emphasize, the only thing soldered to this PCB was the uC, everything else was implemented in the breadboard.

Then I decided to move forward and make a new PCB that includes all common components like power connections and capacitors, cystal oscillator circuit, some headers for common peripherals (like USART1, SPI1, etc.) and BOOT0/1, following the same tiny DIP PCB shape which would be easily mountable into my breadboard.

When the newly designed PCB arrived, I soldered all components, applied power to it and voil�! The crystal does not start at all!

I used the same crystal as my previous tests and the same capacitor values (this time in SMD 1206 packages).

My first guess was that the crystal was defective so I replaced it with a brand new one but the same thing happened. It does not oscillate; but I can connect to the uC through SWD, program the flash memory and I can even load a program (blinky test) but of course it doesn't work at the expected frequency.

I've tried everything and nothing works. I've been through Application Note ''AN2867 - Oscillator design guide for STM8S, STM8A and STM32 microcontrollers'' a couple of times. I did all the calculations and it seems to me that my oscillator circuit should work (the crystal I'm using is

http://cfm.citizen.co.jp/english/product/pdf/HC-49_U-S.pdf

in case anyone would like to make the calculations).

I even connected an oscilloscope to one of the crystal leads in my first circuit (the one in the breadboard) and I can see a beatufil 8 MHz sinusoidal signal. The same is not true for the crystal circuit mounted in my second PCB.

I don't know what else to try or what else to do. Maybe just give up and try to make a new PCB.

I attached my schematics and also an image of the routing in my PCB around the crystal oscillator (note that because of size constraints I placed oscillator capacitors in the bottom layer of the PCB).

Please take a look at these files and tell me if you have any advice or if you spot any error or potencial problem. I don't know what else to try. I know I might not have followed all crystal layout recommendations in AN2867 as I didn't know about them at the time I designed the PCB, but I feel the oscillator should work anyway. Please let me know if you think it should not. I'm sure the schematics could contain some errors as this is my first PCB with an STM32 uC so bare with me :)

Thank you so much for your help and time in advance.

Best regards,

Andy

#oscillator #dip #hse #pcb
7 REPLIES 7
Posted on October 28, 2014 at 09:33

As the oscillator amplifier is in the analog supply domain, C6 and C7 should be returned to AGND (VSSA, pin 8), especially since you decoupled GND and AGND. The return path to VSSA pin should be as short as possible.

Also, check or replace the capacitors - as  there is no marking on SMD capacitors, quite often they get confused for other values.

JW

stm32forum
Associate II
Posted on October 28, 2014 at 09:35

According my calculation the C's should be 10pF with this crystal, if you take 5pF for the pcb in consideration.

I can't see the whole pcb but it looks like that the tracks are going also somewhere else, not only to the C's, crystal and the mcu.

If these are going to a header and/or breadboard  it will give a to big capacitive load and therefore the crystal won't start.

andyolivares
Associate II
Posted on October 28, 2014 at 13:40

Hi

waclawek.jan

& Edje:

Thank you so much for your answers.

''As the oscillator amplifier is in the analog supply domain, C6 and C7 should be returned to AGND (VSSA, pin 8), especially since you decoupled GND and AGND. The return path to VSSA pin should be as short as possible.''

I din't know that the oscillator amplifier is in the analog supply domain. I guess it makes sense now :) I'll try to connect AGND to GND directly. Do you think that if removing L1 and replacing it with a 0 ohm resistor would work?

I know that the return path won't be as short as possible but maybe I could get the crystal to oscillate.

Also, check or replace the capacitors - as there is no marking on SMD capacitors, quite often they get confused for other values.

Yeah, I might replace the capacitors. Unfortunately, due to the small capacitance (pF) I can't measure the capacitors with my Fluke tester to make sure it's the right one. I have to trust the store that sold me the capacitors.

Unless you know a way to test such small capacitances.

Also, do you think that the capacitors being in a different layer makes any difference?

According my calculation the C's should be 10pF with this crystal, if you take 5pF for the pcb in consideration.

I also tried with 10pF capacitors with the same luck. Anyway, it is my understanding that these capacitors are not critical in the oscillation (as it has to do more with the gain margin) but in the frequency tunning. I think (and correct me if I'm wrong) that if I get the capacitors wrong, I would get an off-tuned oscillation.

Also, the STM32F103C8T6 datasheet states that ''PCB and MCU pin capacitance must be included (

10 pF can be used as a rough estimate of the combined pin and board capacitance) when sizing CL1 and CL2''. If I use 10pF in my calculations, I get that:

C = 2*(CL-CS) = 2*(10pF - 10pF) = 0 where CL: load capacitance & CS: stray capacitance

Which is pretty weird in this case. So, I used CS=5pF as you did :)

I can't see the whole pcb but it looks like that the tracks are going also somewhere else, not only to the C's, crystal and the mcu. If these are going to a header and/or breadboard it will give a to big capacitive load and therefore the crystal won't start.

Yes, those tracks are going to a header and then to the breadboard. I wonder why it works in my first PCB and it wouldn't work in this one.

I'm attaching the whole PCB for your reference.

Thank you for all your time :)

Andy

________________

Attachments :

pcb.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1KY&d=%2Fa%2F0X0000000blN%2FWTaTTA5gcY77bHc7f.q1n.IWA0lgxXJLPqXB6AX1Big&asPdf=false
Posted on October 28, 2014 at 20:35

Andy,

- don't try it to get running while placed in the breadboard. Connect only power and the debug header, if needed.

- I don't see where the two grounds to which the capacitors are connected, meet.Short the pad closest to pin 8 (AGND) directly with both capacitors' grounds by a wire. You want to get it working; you can think about aesthetics later.

- If still no joy, use the capacitors from your first design, which is known working, even if they are through-hole. Or, do it the other way round, replace the capacitors (one at a time) in the working design by those from the not workning one

Jan

andyolivares
Associate II
Posted on October 29, 2014 at 01:41

Thanks Jan! I'll try what you suggested and let you know.

Regards,

Andy

Chris1
Senior III
Posted on October 29, 2014 at 20:10

Also, make sure that you are enabling the HSE clock in your firmware.

andyolivares
Associate II
Posted on January 06, 2015 at 16:50

Hi everyone:

I haven't had the time to update you all on this issue, but I finally solved it.

I made a second prototype taking into consideration all of your suggestions and making a commong ground (GND and AGND are all connected together).

Now the chip works fine and the oscillator works like a charm (a clear and steady 8 Mhz signal shown in the oscilloscope).

Thank you very much,

Andy