Skip to main content
Associate II
August 23, 2019
Question

One Pulse Mode input can not be driven high enough.

  • August 23, 2019
  • 3 replies
  • 1871 views

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!!!

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
August 23, 2019

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

ming2Author
Associate II
August 24, 2019

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?

Tesla DeLorean
Guru
August 23, 2019

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
ming2Author
Associate II
August 24, 2019

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.

PPark.1
Associate II
March 11, 2020

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);