cancel
Showing results for 
Search instead for 
Did you mean: 

Creating software based retriggerable one pulse timer

HZaib.1
Associate III

Hi, I want to create a timer with retriggerable pulse of specified length. 

Now I know timer can do it, but there is an issue with one pulse retriggerable mode that needs to be from outside trigger otherwise it dont work. My application is specific and it needs retriggerable mode but internally not from external source. Now the simple solution would be give gpio to one of the sources and route it to that trigger pin and do that way, but the issue is PCBs are already manufactured and no changes can be made, so it is upto me to solve it in software now. 

 

Is there any software solution I can do mimic this oneshot pulse timer ? I tried other methods with output compare and stuff but that does not work well. 

11 REPLIES 11

STM32G071. I've done brief tests. I've used TIM3 to generate 1Hz TRGO (update event). TIM2 in one pulse mode (300ms pulse), slave mode set to "combined reset + trigger from ITR2 (TIM3), output compare mode set to "RETRIG_OPM2". I've seen pulses with 1Hz period on TIM2 output. From this I conclude that I have the mode set correctly. 
Now i disable TIM3 and call in main() every 500ms:
LL_TIM_EnableCounter(TIM2);
TIM2->EGR = TIM_EGR_TG;
and then i do not observe any pulses at the output (same without "EnableCounter").
Similar coniguration, but with "nonretriggerable" pulse works well. May be i am wrong and missing something, but it looks like that "retriggerable" mode cant be triggered by SW on G071... until somebody prove opposite :D

HZaib.1
Associate III

So I can confirm now after alot of testing that. Retriggerable timer cannot be done with software trigger update only from external source or internal timers it can be triggered. 

In the end after using 2 timers I was able to achieve what I was trying to do. 

 

Here is a screen shot what Retriggerable pulse looks like. 

Channel 0 is Retriggerable timer pulse 

 

HZaib1_0-1707530004372.png

So it is working quite well but not happy with how stm implemented this simple functionality with such a complication.