2024-01-25 06:33 AM
Hello people, i am making a project using STM32F407VG and i am using a timer that drives a laser. The problem is, when debugging STM is probably pulling couple of its pins to High state before i start F8 (between pressing the 'Debug' button and F8 to stop the program waiting at HAL_Init() function after i run the code it switches back to LOW state ) and messes up with my laser circuit. I want to know which pins go to High state and why, and see if i can control it i really have to deny it pulling to high state. Thanks for the help. Have a great day !
Solved! Go to Solution.
2024-01-25 08:10 AM
No, there is no way to change the default pin states upon reset.
2024-01-25 06:40 AM
A few pins are initialized as debug pins by default, but the vast majority of pins are initialized as input.
Which pins are you having issues with? Pins that are not in input mode after reset are PA13, PA14, PA15, PB3, PB4.
2024-01-25 07:55 AM
This is typically due to the default configuration of these pins under reset or during boot
If you are using JTAG for example, JTAG pins maintain their pull-up and pull-down resistor settings even under reset
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-01-25 08:07 AM
is there any way to control this? i am using SW debug btw
2024-01-25 08:10 AM
No, there is no way to change the default pin states upon reset.
2024-01-25 08:56 AM - edited 2024-01-25 08:57 AM
Probably going to need some better interlock / fail-safe mechanisms, so that dead-stopping in debug, fault or watch-dog conditions don't cause dangerous conditions to occur or persist.
Watch also what DBGMCU does with suspending TIM, clocks, etc.
Have your system be aware it's running under a debugger.
Might also look under the MOTORs sections / docs as this might address similar situations
2024-01-25 09:31 AM
How do you control state of used GPIOs when they are not initialised (MCU in reset state, or starting up) ? Are they equiped with some external pulldowns or left floating ?
2024-01-25 09:55 AM
@Michal Dudka wrote:How do you control state of used GPIOs when they are not initialised (MCU in reset state, or starting up) ?
You can't - the reset state is defined by the hardware.
As others have already said, most GPIOs default to being inputs.
For full details, see the datasheet.
2024-01-25 11:23 AM
Of course i can. For example by external pull-up/pull-down resistors. By my qustion i only want to rule out the possibility that his "laser control output" is left floating during reset/startup. Because in that case it can reach any value, due static charge, or by its "load" and can be misinterpreted as MCU intentional action.
2024-01-25 03:21 PM
I mean, you can't control the the pin states by any configuration or programming of the microcontroller; so, yes - you have to do it by external hardware.