cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 series PWM out logic level at reset and pause state

NEdom.1
Associate III

I am using STM32F103RCTx and STM32CubeIDE for developing a small application.

I am tuning a vacuum pump DC motor using PWM signal with TIM1 CHANNEL_1. But I hit a small problem when I start debug the board. The motor is running from the time the IDE starts reset & downloading program to the MCU until I click at RUN to run the program. This is very annoying when I debug the program in the office.

Here is the TIM1 setting. The PWM frequency is 2kHz, polarity HIGH and CH Idle state Reset.

NEdom1_0-1698624497618.png

Is there any way to make the PWM Channel output certain at debug stage before I click RUN by config only the MCU without extra circuit? Just like controlling the LEDs. The LED configured as GPIO OUPUT does not turn LED ON until program running.

Thanks for the help.

1 ACCEPTED SOLUTION

Accepted Solutions

Which pin?

Most pins are after reset set to Input, i.e. they don't output any definitive level. Exception are the JTAG pins which are pulled up/down, see datasheet.

Also, if your controller has some internal pullup/pulldown, that will determine the level during reset.

In all above cases, you'd need to add your pullup/pulldown to determine level at reset.

Another case may be, that the debugger does not hold the mcu in reset all the time it downloads it, in which case the pin's state is determined by... many factors. You can test that simply by holding the chip in reset using pushbutton reset. If motor does not run, then  just find a setting in your toolchain which allows to hold the mcu in reset while downloading.

JW

View solution in original post

4 REPLIES 4
Shirley.Ye
ST Employee

Not understand your point. If you are using Cubefirmware, there is HAL_TIM_PWM_Start function. After you configured the PWM Channel output, you need to the call the HAL_TIM_PWM_Start, then the PWM channel begin to output.

Which pin?

Most pins are after reset set to Input, i.e. they don't output any definitive level. Exception are the JTAG pins which are pulled up/down, see datasheet.

Also, if your controller has some internal pullup/pulldown, that will determine the level during reset.

In all above cases, you'd need to add your pullup/pulldown to determine level at reset.

Another case may be, that the debugger does not hold the mcu in reset all the time it downloads it, in which case the pin's state is determined by... many factors. You can test that simply by holding the chip in reset using pushbutton reset. If motor does not run, then  just find a setting in your toolchain which allows to hold the mcu in reset while downloading.

JW

Thanks for sharing the info of MCU's reset states.

The motor runs when I am holding reset button. The PWM pin output 2.33V when RESET pin is low. Maybe I need to add some extra circuit to make it work.

Thanks for reply. I do use the HAL functions to control PWM signal. The board runs normally by itself. What bothers me is that when I am debugging the board.