cancel
Showing results for 
Search instead for 
Did you mean: 

One Pulse Mode input can not be driven high enough.

ming2
Associate III

Hello folks,

Does any body know why the input pin can not be driven high enough when it is set as the trigger to TIM3 in OPM? I use CubeMX to generate the init code where TIM3 ch1 as input trigger and ch2 as the output. On the board, I use a comparator to drive ch1 but it is going only 0.9v high! It can go 3.3v without driving ch1. Why? I need to fix it asap. Thanks!!!

7 REPLIES 7

Are you sure the pin you are trying to drive is turned to input (i.e. pin set in GPIO _MODER as AF and set to proper AF for the timer in AFR; in timer CMMR set to input capture)? Read back and check the relevant GPIO and timer registers' content.

JW

Does seem very odd. Honestly wouldn't trust CubeMX myself.

Sure there isn't a short of something? Something else on same pin to other parts of the circuit? What Pin/part specifically? STM32 super vague description.

What is the drive capability of the comparator? Does it work if you buffer it?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I have checked for connectivity errors and there is no. the comparator is working fine without driving PA6, the TIM3 Ch1. It can sink/source 20mA and I think it is more than enough to drive a MCU input pin...

I also tried to use MCU pin output a pules to it, and it is going higher about 2v with respect 3.3v Vdd. It was able to trigger OPM since it was over threshold. But the comparator can not. Anyway, it seems somewhere about the pin initialization went wrong...

It is stm32F303RE. PortA.6 for input capture of TIM3, PortA.7 for PWM output the pulse.

How to varify the pin init? I use CubeMX which automatic create the code for me. Can you share some code other than MX? Thanks

I use STM32F303RE, TIM3 in OPM, PA6 in/PA7 out.

I forgot to mention that TIM3 ch3 and ch4 were also used for capture and output respectively for different purpose. Would it be related?

0690X00000AAIALQA5.pngHi, JW,

I am not sure and it is my concern that in CubeMX, it is still left as output since it became unavailable when TI1FP1 is select as input trigger. See the PIC.

I feel it is still an output pin since it could not be driven high.

Thanks

Read out and check the actual GPIO and TIM registers'content.

The mcu works out of the registers and does not care about what is ticked and clicked in CubeMX.

JW

PPark.1
Associate II

I have just been having the same problem with an STM32F205, and have reproduced the problem with an STM32L476 Nucleo board.

The problem appears to be in the HAL_TIM_OnePulse_Start() function. The comments in the function definition say:-

 /* Enable the Capture compare and the Input Capture channels

  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)

  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and

  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output

  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together

...*/

There appears to be a misunderstanding of enabling the channel - the CCnE bit in the TIMx_CCER is defined in the Reference Manual as being the Output Enable, and therefore should not be set for the input channel.

I have therefore implemented a workaround of disabling the CCnE bit for the input channel immediately after the call to start One-Pulse Mode.

HAL_TIM_OnePulse_Start(&htim2, TIM_CHANNEL_2);

TIM_CCxChannelCmd(htim2.Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);