cancel
Showing results for 
Search instead for 
Did you mean: 

Pulse width measurement under interrupt

NDicostanzo
Associate II

Hello everyone,

I'm designing a new system based on the STM32F746BET6.
Basically it's just reading and writing GPIOs and receiving/transmitting data through a few interfaces (ethernet and I2C). The system receives a 100 bit/sec data frame every second for time tagging (IRIG-B) and have to measure time width of every pulse received in order to decode the message (width of every pulse varies from 2 ms to 8 ms).

My idea is capturing every rising and falling edge with a timer and then calculating time difference in order to obtain the pulse with. Still, I have a few questions about it.

1) To do so, my system will get an interrupt everytime an edge is detected on my timer pin. Will this stop the uC from its tasks everytime an edge is detected?

2) Do I really need a timer to detect edges or is there some other way to get pulses width?

Thank you very much in advanced  

4 REPLIES 4
SofLit
ST Employee

Hello,

Maybe I suggest using PWM input with which you can measure the high pulse and the period. Maybe also using DMA timer request to receive a burst of pulse and then calculate all the pulse durations after..

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Hello,

Thank you for your answer. Will I still get an interrupt everytime I get an edge on my PWM input?

Thank you very much in advanced.

No with DMA you will get an interrupt at the end of DMA transfer. For that you need to set the data to transfer > 1.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@NDicostanzo wrote:

my system will get an interrupt everytime an edge is detected on my timer pin. Will this stop the uC from its tasks everytime an edge is detected?  


An interrupt blocks software executing at lower priority.

So it won't block the hardware operations of stuff like the I2C and Ethernet peripherals.

This is why it's important to keep interrupt handlers as short (timewise) as possible