2024-02-17 07:15 AM
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.
Solved! Go to Solution.
2024-04-05 12:17 PM
Hi,
I would not call this a final solution. According to Jan Waclawek (who is more knowledgeable about these matters ) HAL_OnePulse_Start function is for software start PWM to produce pulses after a delay. In my case I do do this, but instead start the PWM using a pulse applied to a pin.
The following from one of my previous posts explains what to do and how it works. I have used this on a range fo different counter/timers on STM32L486 and STM32H7A3. I currently use this method with two counter/timers (TIM 8 and TIM15) it to generate pulses with precise variable delays and width (1 clock pulse jitter) after a hardware pulse without the jitter associated with processor or bus latency.
I hope this helps!
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 ;
The extra line 2 resolved the problem for me.