cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 TIM TI2FP2 GPIO very high input current on pin problem

HWhit.1
Associate III

I am trying to make a precise delayed pulse for my project that does not use interrupts. I plant to use TIM1 or TIM8 on a STM32H7A3 using the TI2FP2 input to trigger and reset the counter in one-pulse mode.  I tried the method describe in website.  Controllerstech.com  https://controllerstech.com/stm32-timers-9-one-pulse-mode/   This worked as expected when a switch to the +3.3 V line was used as a trigger. When I connected to a open-collector LVTTL  output the trigger pulse disapeared.  It turned out the  electrical impedance was extremely low. after HAL_TIM_OneP...

I measured the current from the +3.3 V line to the TI2FP2 input (PE7) to be 102 mA. I would expect this to be max a few microamps.

STM32 Timers #9. One Pulse Mode || Retriggerable OPM

The problem was reproduced for TIM1 and TIM15 on the same board and also TIM1 on a STM32L476 board - so it seems to be a problem with the HAL.

My questions:

(i) What does the reset state on a GPIO pin mean? Does this mean the input is connected to ground?

(ii) Is it possible to correct this by writing to GPIOE_MODER register to set to the alternate fumction to set the mode on PE7 to 0x2  (= alternate function)?

I am grateful advice on how to deal with this.

 

 

20 REPLIES 20

> (If Cube would be perfect, it should show a warning: "Set used channel as input, to use input signal TIxFPy." )

I don't get it. Is the complaint here, that a pin assigned to TIM channel set to Output Compare, is actually Output?

JW

Your close. 🙂

Not setting a channel as anything seems to set the OC on, after the timer start/compare. (HAL_TIM_OnePulse_Start())

As @HWhit.1 writes : Before this command is executed the impedance to ground was high ...

I never had a problem with this, but i also never forgot to set the used inputs as inputs.

Works as expected then.

If you feel a post has answered your question, please click "Accept as Solution".

Oh, now I see.

HAL_TIM_OnePulse_Start() is NOT what you'd think based on its name.

It's a recurring theme here.

JW

Hi,

Even when CC2 is set to input in ititialise by:

if (HAL_TIM_OnePulse_Init(&htim8, TIM_OPMODE_SINGLE) != HAL_OK)
{
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_COMBINED_RESETTRIGGER;
sSlaveConfig.InputTrigger = TIM_TS_TI2FP2;
sSlaveConfig.TriggerPolarity = TIM_TRIGGERPOLARITY_RISING;
sSlaveConfig.TriggerFilter = 0;
if (HAL_TIM_SlaveConfigSynchro(&htim8, &sSlaveConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}

The pin pin became low impedance to ground exactly when HAL_TIM_OnePulse_Start(&htim15,TIM_CHANNEL_1); was executed. The solution was to do a direct register write directly afterwards to set bit CC2E to zero which disables OC2 and the pin reverts to a high impedance state where it acts as an input. The code is for TIM15,

HAL_TIM_OnePulse_Start(&htim15,TIM_CHANNEL_1);
TIM15->CCER = TIM15->CCER & 0xffffffef ;

This extra line resolved the problem for me.

The problem seems to have the character of a bug in HAL because to my mind executing a HAL_TIM_OnePulse_Start should not modifiy the initialised register values as to which channels are set to input compare and which are set to output compare. However, there might be an underlying reason for doing this - but it is not obvious to me as to why this should be so.

H.

 

Hi,

i used only other modes, not "one pulse" , so maybe just one pulse has a problem.

I could try it on (just have it here) F303 , TIM3 . ch1 as TI1FP1 , ch3 as output (to see on scope).

To check: is it a bug in HAL - or ... 

If you feel a post has answered your question, please click "Accept as Solution".

Please read what I wrote above, and the links I've given there.

Also, please read the associated documentation.

Just reiterating: HAL_TIM_OnePulse_Start() and its "framework" is *not* what you think based on its name, i.e. it's *not intended* to produce one single pulse on one output of the timer upon calling this function. It is intended to demonstrate one particular example from the RM (which is one of the many examples which don't not belong to RM and should be moved to an AN, but that's another issue), namely this one:

waclawekjan_1-1710361092389.png

So, it always uses *two* channels, one set as input, and other as output. If you don't set them using the methods intended (which I am not interested in finding out, but you should really examine the example in Cube which is intended to demonstrate HAL_TIM_OnePulse_Start()), those two channels will set neither as you intended, nor as that example intended.

As you may have noticed, I don't use Cube/HAL, so I am not really interested in getting it more usable.

JW

Now 2 hours later...

on F303 : 72MHz core + timer

TIM3 . ch1 as TI1FP1 , ch3 as output 500us pulse, 1500us delayed (blue)

TIM8 .ch  100us pulse every 5ms as trigger (yellow)

 

AScha3_0-1710364451474.png

Cube setting:

AScha3_1-1710364561313.png

AScha3_2-1710364609877.png

start in main:

 

  HAL_TIM_OC_Start(&htim3, TIM_CHANNEL_3);

 

 

 

If you feel a post has answered your question, please click "Accept as Solution".

So... is there a final solution here? I'm facing the same problem, following the controllerstech tutorial...

Didnt you see my last post ?

Exactly what it should do.

If you feel a post has answered your question, please click "Accept as Solution".

That does indeed appear to fix the low impedance problem on TI2FP2