cancel
Showing results for 
Search instead for 
Did you mean: 

XORed Input capture with timer

michaellange9
Associate II
Posted on September 17, 2008 at 05:38

XORed Input capture with timer

5 REPLIES 5
michaellange9
Associate II
Posted on May 17, 2011 at 12:44

PWM input mode was a good idea. Channel 1 for the rising edge and channel 2 for the falling. Now it is working fine.

Thanks a lot!

Michael

tibo
Associate II
Posted on May 17, 2011 at 12:44

I am not familiar with hall signals, but if you want to capture on both edges you can

use two timers in capture mode with opposite direction and link them together. You

can find more info's about timer linking in AN2592. Another possibility to capture on

both edges with one timer is the PWM Input mode (RM0008, page 286).

michaellange9
Associate II
Posted on May 17, 2011 at 12:44

Hello,

I'd like to capture three hall-signals with TIM2 and generate an capture interrupt at every change of the hall state. I have XORed the channels and can capture at every rising edge of a signal change. That is working, but I can detect only every second state.

How can I capture at both edges, rising and falling? Or must I invert the capture polarity at every edge?

Michael

tibo
Associate II
Posted on May 17, 2011 at 12:44

I have an idea for an improvement (but I have not tested it at the moment …):

with PWM Input mode you get for the first measurement the relative time (the

time since the last transition) and for the second measurement the ''period''

(the time for the whole cycle). To get here the relative time you have to make

a calculation.

In time critical application or if you want to collect the values with DMA, then the

calculation is or may be a problem.

If you select the mode TI1F_ED for TS in TIMx_SMCR, I think you will get the

true relative values in the capture register for both transitions (see page 237 and

note on page 309 in RM0008).

If this is an interesting topic in your application and you will test it, I am very

interested in your results.

michaellange9
Associate II
Posted on May 17, 2011 at 12:44

Good idea. I tested the following configuration:

TIMx_SMCR, SMS = 100 //Timer in Reset Mode

TIMx_CR2, TI1S = 1 //Channel Inputs XORed

TIMx_SMCR, TS = 100 //TI1 Edge Detector (TI1F_ED)

Channel1:

TIMx_CCMR1, CC1S = 11 //IC1 is mapped on TRC

TIMx_CCER, CC1E //Channel 1 enable

TIMx_DIER, CC2IE //Channel 1 Capture Interrupt enable

It is working like you supposed. In CC1 is always the time between two edges.

Interesting. I have to think about which version I will choose for the closed loop control. Simple control is working with both variants.