2008-09-16 08:38 PM
XORed Input capture with timer
2011-05-17 03:44 AM
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! Michael2011-05-17 03:44 AM
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).2011-05-17 03:44 AM
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? Michael2011-05-17 03:44 AM
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.2011-05-17 03:44 AM
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.