2020-12-26 06:16 AM
I have a project using an STM32L412. It works fine on my bench power supply, but I made it to run on a piece of modular equipment which has a different power supply - this supply is slower starting. On this supply the board seems to work fine except the ADC freezes on power up - the PWM for the LEDs still works, the external interrupts still work, however the ADC is completely unresponsive. If I remove the reset capacitor, the circtuit then works on the slower starting power supply and not on the faster starting one. I need to be sure that it will work on every power supply - is there code for optimising this?
2020-12-26 06:56 AM
How do you know the ADC is frozen? What do you mean by "the ADC is completely unresponsive"?
It makes no sense that the CPU would be running other peripherals but not the ADC.
2020-12-26 07:15 AM
allow me to explain - my circuit is a piece of audio equipment - a wave goes in, it is compared to generate a square wave as it crosses 0. This is fed to an external interrupt pin, the interrupt modifies the signal and puts it back out on one of the pins.
A pot connected to the ADC is used to alter how the program modifies the signal, the value from the ADC is also used to control the colour of the LEDs
When the board is connected to this slower starting power supply, the LEDs do not change colour as the pot is changed (the voltage on the ADC pin is still there as verified with a scope) the wave is also not modified as the pot is changed. There fore I conclude the ADC has frozen/ is broken/unresponsive etc.
When I remove the 100nF reset capacitor, the circuit works fine, but i then have the opposite problem that it doesn't work properly on my bench power supply
2020-12-26 07:28 AM
Okay, so the CPU could just be stuck in the code somewhere as well, that would also explain the symptoms.
Attach a debugger to the board when it's in this state to see where it's at. You can attach a debugger after the board has frozen without resetting the chip.
To debug your program without downloading it:
Go to Debug Configurations... -> Startup -> select load image -> Edit... -> uncheck Download
To debug without resetting the device:
Go to Debug Configurations... -> Debugger -> in Reset Behavior, select "None"
2020-12-28 03:58 AM
Thanks. I did this and I found that the code seemed to run fine - i could step through the whole program and anywhere I put a break point, it was reached. The registers are exactly the same - except when i run it with the *problem* power supply, the ADC calibration returns 0 and the ADC always returns 0x800.
Sometimes I get problem when I *step into* the wait loop for the ADC conversion to complete, that's the only functional difference I could find
Can you give me any advice on what I could check next?