2022-06-03 08:05 AM
Hello dear friends
I use the stm32f4 series. I am looking for some code to retrigger a similar pulse. To be clear, I have some circuits for zero-cross detection. Now, for each input pulse before the next in[ut pulse, I want some output pulse that would be triggered after some specific delay time, by which the output pulse is zero in delay time and active after delay, and would become zero when the next input pulse is caught. I considered using Either external interrupt or timer input capture mode for the input pulse. But for external output, my research has led me to timer one pulse mode. I couldn't find some example code with results on the internet.
The signaling is as shown in the image. T1 is the delay and T2 is the time that signal is active. For a 50hz input pulse, T1+T2 will be 20ms. What I want is a code that doesn't block MCU in the interrupt routine and T1 could be controlled.
The .ioc file is attached.
help me, please
Solved! Go to Solution.
2022-06-03 02:10 PM
Drawback of this method is, that if the stream from the zero-cross detector stops, the timer overflows and then stops too, and there will be no more pulses. If this is something which happens rarely, I would enable interrupt upon Update (= overflow) and handle this situation in software in the interrup.
JW
2022-06-03 08:49 AM
I don't understand what you want to accomplish. Can you please draw a timing diagram?
JW
2022-06-03 12:43 PM
Dear @Community member
Thank you for your response
The question is edited and I hope that it has become clear.
2022-06-03 02:10 PM
Drawback of this method is, that if the stream from the zero-cross detector stops, the timer overflows and then stops too, and there will be no more pulses. If this is something which happens rarely, I would enable interrupt upon Update (= overflow) and handle this situation in software in the interrup.
JW
2022-06-03 09:19 PM
Dear @Community member
Thank you for your response, would you please check the .ioc file I have attached to the question if it complies with your instructions?
2022-06-04 12:15 AM
I don't use Cube/CubeMX, sorry.
JW
2022-06-05 09:03 AM
Dear @Community member
All that you said should be done. But I have one question that couldn't find in the datasheet. When I start the OPM, I expected the timer to stop on arr and be able to restart the timer anywhere else, but I couldn't do that, alternatively, I made arr a bit longer stopped the timer, and restart that.
Also I should mention that TIM.in1 and TIM.out2 share the same code in cube generated code, so I shifted to TIM.in1 and out3