Skip to main content
AGHAZ
Associate II
March 23, 2019
Question

I work with the TIMER2 in INPUT CAPTURE mode, the interrupt is triggered on rising or falling edge. I want to get both trigger times on both fronts using the conditional statement "if" and the HAL library.

  • March 23, 2019
  • 8 replies
  • 1309 views

..

This topic has been closed for replies.

8 replies

Tesla DeLorean
Guru
March 23, 2019

Your best course of action is to use Indirect mode on a second channel. ie CH1 Direct for one edge, CH2 Indirect (from CH1) for the other edge. This will tend to be safer as it gives you more leeway on the interrupt latency. You can also do a quick A-B measurement of time for the two edges.

The measurements will be in TIMx->CCR1 and CCR2

CH3 and CH4 can also pair in a similar fashion.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
March 23, 2019

What is the core SYSCLK frequency and what is the max frequency of the incoming signal to measure rise and fall edge? What Clive mention (A-B) is usually the best. If you can't have 2 pins on the same signals, if there is enough time, you can also capture the timer compare value, double confirm the edge by sensing the GPIO level (it's low or high during the interrupt) then save it for later substraction.

AGHAZ
AGHAZAuthor
Associate II
March 23, 2019

thank you for your answers, I will try both solutions.

S.Ma
Principal
March 23, 2019

Bonne chance!

AGHAZ
AGHAZAuthor
Associate II
March 23, 2019

The core frequency SYSCLK I defined it at 100HZ, the frequency of the signal to be measured I will check it as soon as possible. Firstly, I want to find a starting solution.

I put you in the frame: I work with an UltraSon sensor and I want to measure the two rise and fall times of the Echo signal, so I only have one input. I think I can not work on two TIMER channels for the moment.

S.Ma
Principal
March 23, 2019

So use timer channel 1 and 2 of a timer and activate interrupt on both rise and fall edge of both channel.

Activate the interrupt on both channels.

The higher the timer frequency the more precise the delta measurement.

AGHAZ
AGHAZAuthor
Associate II
March 23, 2019

but how can I use two channels of a timer for only one input !

S.Ma
Principal
March 24, 2019

You are mentionning 2 rise and 2 fall time, meaning you probably have 2 signals to measure or 1 as output and 1 as echo feedback. If they are both pulses, they should be generated possibly from the same timer.