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  

6 REPLIES 6
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

 

That's the point.

I cannot block all the other software instructions everytime I get an edge on my interrupt pin. Still, I have to measure time width of all the pulses.

I was considering to add another microcontroller for handling the with measurement operation, then send data via I2C to the main mcu which will be interrupted upon reception.

You can use DMA to store the captured timestamps to a buffer in RAM, and then process it later, whenever you see it fit.

JW