STM32 external crystal problem - Page 1
Forum section: electronics / general

author: Hacked
author_rank: Contributor
timestamp: September 15, 2022, 06:15:54 am
content: 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

author: darkspr1te
author_rank: Frequent Contributor
timestamp: September 15, 2022, 06:38:47 am
content: 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

author: Hacked
author_rank: Contributor
timestamp: September 15, 2022, 06:46:59 am
content: Quote from: darkspr1te on September 15, 2022, 06:38:47 amI 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?

author: darkspr1te
author_rank: Frequent Contributor
timestamp: September 15, 2022, 06:59:26 am
content: no idea, i just found this works.darkspr1te

author: Hacked
author_rank: Contributor
timestamp: September 15, 2022, 07:09:09 am
content: Quote from: darkspr1te on September 15, 2022, 06:59:26 amSo you had the same problem as I?

author: Hacked
author_rank: Contributor
timestamp: September 15, 2022, 12:06:16 pm
content: 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.

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 15, 2022, 12:11:06 pm
content: 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.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: September 15, 2022, 01:08:05 pm
content: Quote from: Hacked on September 15, 2022, 12:06:16 pmIf 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

author: Hacked
author_rank: Contributor
timestamp: September 16, 2022, 05:50:45 am
content: 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?

author: Hacked
author_rank: Contributor
timestamp: September 16, 2022, 04:33:55 pm
content: Well feck it, I ordered microcontrollers from farnell, hope those aren't fakeNever again will I order from ebay or aliexpress microcontrollers, except from WeAct store.

author: Siwastaja
author_rank: Super Contributor
timestamp: September 16, 2022, 04:39:02 pm
content: 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.

author: thm_w
author_rank: Super Contributor
timestamp: September 16, 2022, 10:04:53 pm
content: 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.