cancel
Showing results for 
Search instead for 
Did you mean: 

Best solution for external triggered timer NON-retriggerable one shot output?

andrewandrew91
Associate II
Posted on March 23, 2018 at 04:53

Moved to questions as suggested....

5 REPLIES 5
Posted on March 23, 2018 at 21:49

Timer in One-Pulse mode (whole section about it in datasheet) create waveform as you describe (at picture in another post). Use TIMx_ETR, TIMx_CH1 or TIMx_CH2 as trigger input. Enable interrupt from trigger event. Once you enable 'Trigger mode' in Slave Mode Controller, timer waits for first selected edge and starts. In Interrupt routine disable Slave mode and timer will ignore all next incoming pulses ... interrupt should had higher priority, because you have only about 1.5us to react and deactivate trigger, but it's more then enought.

Posted on March 24, 2018 at 01:22

Moved here

https://community.st.com/0D50X00009XkfJFSAZ

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 24, 2018 at 21:53

Thanks Clive.  I was out Friday afternoon and did not have a chance to post the link.

Posted on March 24, 2018 at 22:16

So from the feedback I have received it sounds like there is really no way to do this without using an interrupt or some external hardware (AND gate / gated buffer and a pull up resistor). Timing is tight so I wanted to avoid software and interrupts if possible to keep the output pulse within the required window. In the question thread I had posted the fact I was looking at using the STMF4 series and that the final part may have usb capabilities. My concern was if I did enable usb then the usb interrupts could interfere with the pulse timing leading to an unwanted second output pulse being triggered. Maybe I'm just being overly cautious with 180 MHz ARM chip where instructions are executed in the 5-6 ns range?

The interrupt version of my previous solution is more or less in line with what you suggested. The only significant difference is that I use the interrupt at the start of the timer to disable the slave mode / repeat rather than wait until the timer completes. This way the window to cancel the next trigger is much larger while the 1925 ns L+H output pulse is generated.

TIM1_ETH triggers on rising edge of external 1 MHz inputsignal which:

1__starts TIM1_CH1 PWM2 OUTPUT LOW->HIGH

2__generates an interrupt when the timer is started TIM1_CH1 CNT_EN

2a____interrupt disables TIM1 slave mode with TIM1 SMCR |= TIM_SLAVEMODE_DISABLE

If no one sees a flaw in this or has a better suggestion I plan to move forward with this method. Again, I was looking for the best way to do this and it is starting to look like a single interrupt is required to achieve my goal without external hardware.

Feedback appreciated

dudka.michal

Posted on March 25, 2018 at 12:52

I forgot, there is one another option. You can use DMA to reconfigure timer (disable trigger). Timer can generate DMA request by trigger event... thats may be that you are looking for

BTW: you can give timer IRQ highest priority if you use IRQ based solution ...