Author Topic: STM32 external crystal problem  (Read 2040 times)

0 Members and 1 Guest are viewing this topic.

Online HackedTopic starter

  • Contributor
  • Posts: 30
  • Country: hr
STM32 external crystal problem
« on: September 15, 2022, 06:15:54 am »
Hello all,

I ordered STM32F030F4P6 few months back from ebay.
Yesterday I finally tested first piece, and STM32Programmer recognized chip, and I successfully downloaded blinky example from STM32CubeIDE and it worked all fine.
Then I added a 8MHz external crystal (to pin 2 and pin3 as per datasheet) and changed hardware configuration for it (activate external crystal in configuration and in clock settings check if 8MHz crystal is selected and I set the max frequency to 48MHz), but when I downloaded the program it stopped working.
I can't download any new program and STM32Programmer can't connect to it in normal mode but can in hot plug mode. But it won't let me to erase chip flash memory in that mode.
I think I didn't do anything wrong in hardware configuration, I did this before with black pill and blue pills boards and it all worked fine, only thing different this time is that i soldered chip to tssop20 adapter and plug it in breadboard.
I changed crystal and it didn't make a difference. I put two 15pF capacitors which connect crystal to ground and try to change them to 6pF and 33pF but it didn't make a difference.
When I connect oscilloscope I can measure 8Mhz signal but it's just half a Volt peak to peak, don't know if thats normal.
Did I got fake chip? I was pretty sure it was genuine because STM32Programmer connected to it no problems, and I download blinky example ftom STM32CubeIDE also with no problems.
Any ideas would be appreciated.
Want to know if I did something wrong before I try with another one, so I don't brick that one also :D

 

Online darkspr1te

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: zm
Re: STM32 external crystal problem
« Reply #1 on: September 15, 2022, 06:38:47 am »
If you are using STM cube IDE or Cube MX code then you have to remove the jtag disable command in HAL_MSP_init call, located in stm32fxx_hal_msp.c then you will have normal jtag/swd access after programming.

darkspr1te
 

Online HackedTopic starter

  • Contributor
  • Posts: 30
  • Country: hr
Re: STM32 external crystal problem
« Reply #2 on: September 15, 2022, 06:46:59 am »
If you are using STM cube IDE or Cube MX code then you have to remove the jtag disable command in HAL_MSP_init call, located in stm32fxx_hal_msp.c then you will have normal jtag/swd access after programming.

darkspr1te

I use STM32CubeIDE.
I can try that when I come back home, but why would I need to do that with external crystal but not with internal RC oscillator?
 

Online darkspr1te

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: zm
Re: STM32 external crystal problem
« Reply #3 on: September 15, 2022, 06:59:26 am »
no idea, i just found this works.

darkspr1te
 

Online HackedTopic starter

  • Contributor
  • Posts: 30
  • Country: hr
Re: STM32 external crystal problem
« Reply #4 on: September 15, 2022, 07:09:09 am »
no idea, i just found this works.

darkspr1te

So you had the same problem as I?
 

Online HackedTopic starter

  • Contributor
  • Posts: 30
  • Country: hr
Re: STM32 external crystal problem
« Reply #5 on: September 15, 2022, 12:06:16 pm »
Although I can't now remove JTAG disable command because I can't download the program.
First I need to figure out how to unbrick microcontroller or figure out what happened.
 

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3706
  • Country: nl
Re: STM32 external crystal problem
« Reply #6 on: September 15, 2022, 12:11:06 pm »
Select another boot mode with the boot pins and use USB to serial to program the chip. Search with google on how to do this for your chip.

Edit: Attached screen capture form the manual about the boot modes.
« Last Edit: September 15, 2022, 12:17:23 pm by pcprogrammer »
 

Online darkspr1te

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: zm
Re: STM32 external crystal problem
« Reply #7 on: September 15, 2022, 01:08:05 pm »
Although I can't now remove JTAG disable command because I can't download the program.
First I need to figure out how to unbrick microcontroller or figure out what happened.
If you have STCube programmer then load it up, on the right hand side where the stlink setting are select Reset mode as Hardware reset then click the "erasure icon" on the bottom left to erase the device, this should allow you to now flash with your new code.

darkspr1te
 

Online HackedTopic starter

  • Contributor
  • Posts: 30
  • Country: hr
Re: STM32 external crystal problem
« Reply #8 on: September 16, 2022, 05:50:45 am »
Ok, I successfully connected with STM32Programmer via hardware reset and erased the chip flash, same thing I tried 2 days ago but it didn't work.
I tried again to download the program and the same thing happened. It comes to "Download is successfully finished" and it starts to write that it can't connect to host, and trying to reconnect. When all is normal, for example when I download program to my black pill after "Download is successfully finished" it shutdown the connection and all is good, but here it seems that it lost communication as soon as program is downloaded.
I tried to change the crystal to 4MHz but with no success (as you can see in attachment picture), same thing happens.
Now, even when I remove crystal from breadboard and from program configuration it happens same thing which is strange because first day it worked all normal with internal RC oscillator. And now again I can't connect with STM32Programmer to erase the flash, I get the message "No STM32 device found".
I presume I got fake chips.
Is there any way to check via STM32Programmer if chip is fake? Some different register arrangement or more memory or something?
 

Online HackedTopic starter

  • Contributor
  • Posts: 30
  • Country: hr
Re: STM32 external crystal problem
« Reply #9 on: September 16, 2022, 04:33:55 pm »
Well feck it, I ordered microcontrollers from farnell, hope those aren't fake :D
Never again will I order from ebay or aliexpress microcontrollers, except from WeAct store.
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8172
  • Country: fi
Re: STM32 external crystal problem
« Reply #10 on: September 16, 2022, 04:39:02 pm »
Just don't buy any components from aliexpress/ebay. With microcontrollers, chances of getting genuine devices at least are there. Try to buy some simple jellybean ICs like opamps/linear regulators, or discrete semiconductors like MOSFETs, and fake rate is nearly 100%.

It's just not worth it, the wasted time and destroyed projects is too valuable. For a pro, it's an economic disaster; for a hobbyist, it will kill your motivation and possibly destroy the hobby.
 
The following users thanked this post: SiliconWizard

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6378
  • Country: ca
  • Non-expert
Re: STM32 external crystal problem
« Reply #11 on: September 16, 2022, 10:04:53 pm »
How many did you order?

You shouldn't need any crystal to program.
I've seen similar issues and it was because Vdda was not appropriately powered. In your case it looks like you've not connected Vdda at all. Maybe try connect it to Vdd directly.

I've ordered many STM32F030 from alix, one batch was fake (some logic IC remarked), BUT I usually start by getting a few real ones from digikey so I have something to compare to. And never let them sit, always test right when you receive them.
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf