2021-04-23 12:32 PM
Hi, I have an STM32F373. If I have the VREFSD+ tied to 3.3V and have it set to Forced Externally using VREF pin in the SDADC1 of the .ioc file, then the MCU will flash properly.
However, if I disconnect VREFSD+ from the 3.3V, and set it to "Forced Internally to 1.22V VREFINT" in the SDADC1 section of the .ioc file, then the MCU will not flash.
I only get STLink errors in STM32CubeIDE (failed to start GDB server, target no device found, Error in initializing ST-Link device). Reason: no device found on target.
Any help is much appreciated as I cannot debug if STLink won't even connect when VREFSD+ is disconnected from 3.3V.
2021-04-28 12:29 PM
Turns out I had to download STMCubeProgrammer, erase the chip, then it will let me re-flash the chip and debug. It is getting hung up on the SystemClock_Config();. Still troubleshooting why.
2021-04-28 02:57 PM
Now it is getting past Systemclock_Config() but it is now getting hung up inside MX_SDADC1_Init();
2021-04-28 03:11 PM
It is getting stuck inside
stm32f3xx_hal_sdadc.c
at this 2nd line here:
SDADC1->CR1 &= ~(SDADC_CR1_REFV);
SDADC1->CR1 |= hsdadc->Init.ReferenceVoltage;
2021-04-29 03:22 PM
So I found while debugging that it is setting hsdadc->Init.ReferenceVoltage to 256 when Vref is set to Forced Internally to 1.22V instead of 1.
If it to Forced Internally to 1.8V, then it sets that Init.Referencevoltage to 512 instead of 2 (binary 10) like the datasheet says. If I hard-code it to 1, then the STM32 will run the code. Strange because all this is all generated by the .ioc setup.
2021-04-29 03:24 PM
This is what I mean:
//hsdadc1.Init.ReferenceVoltage = SDADC_VREF_VREFINT1; //this is generated by .ioc (does not work) but it gets set to 256 in the debugger.
hsdadc1.Init.ReferenceVoltage = 1; // this works