Background
I am working on a school project where I have designed a prototype PCB with the core being a STM32F042K6T6 microcontroller. I am using the ST-Link from a Nucleo STM32F401RE card to program it.
Problem
When programming the device with some simple code to light an LED, the LED wouldn't light up. While troubleshooting, I accidentally realized that the LED would light up after a fresh "power on" (without changing code or reprogramming the MCU), simply pulling the power supply and then reconnecting it.
This lead me to believe something was wrong with the reseting of the device after the programming. To test this I started from a shining LED after power-on, and then pressing the reset button for a hardware reset. As suspected the LED would go dark and then not light up again. Then when I disconnect the power and reconnect it again it lights up.
Further observations I reckon might get asked.
- The voltage levels of the device seems good, decoupling is placed according to data sheet.
- Reset is implemented with external pull up with a 10k resistor to 3.3V and then a button for shorting to ground on reset and a parallel cap of 100 nF down to ground. (This is connected to the NRST pin on the MCU as well as the NRST pin on the programming connector).
- The LED is a simple SMD led with a 180 ohms series resistance put on GPIO PB5. (Actually have 3 different status LEDs on the board, and can start them all in code
I have probed the "analog" signal of the reset pin, and to me the signal seems fine, dropping low when I click/hold the reset button. And as the LED turns off when clicking the reset button, I believe it starts to restart the program. However it doesn't seem to fully reinitialize and start executing code from the start of 'main()`? As the code actually works to light the LED after a power-on reset. Therefore the correct instructions seems to have been uploaded to the program memory, but the resets (both while programming and on clicking the reset button) seems to somehow fail to reinitialize the .
Any assistance would be greatly appreciated.