2014-04-23 06:33 AM
hi all, I'm new in the forum and I am experiencing a problem of ISR , which doesn't happen for TIM12 while, with same ch1 configuration register and same pwm signal input, set the ISR calling for TIM9, as expected. I am quite surprised of this behaviour and I have checked the TIM9 and TIM12 register configuration but I cant found any difference . I am about to check if there is any errata which may affect the TIM12 functionality: not yet done at the moment. do you have any suggestion? I am new to stm32 device and maybe someone can give me some tips on what to check and debug(keil V5) .
2014-04-24 04:29 AM
The PWM Input Capture mode typically uses two channels and resets the counter to make measurements of duty and period.
You can use the straight-up Input Capture mode, and configure each channel to latch it's own value (instead of tying them together). Provided the speed isn't too high you can measure duty/period of both channels in software. Not sure if TIM9/TIM12 support both edges. The diagrams for TIM9/TIM12 are awful, as I recall the bits to select the trigger source and other muxes are totally missing. At least as described at the register level, and not useable in reality.2014-04-24 08:10 AM
Hiclive, the TIM9 supports both edges, though , withcapture input mode I can only get one counter, as duty or period, butnot both, isn't it? In my project I am not sure I can't makeassumption on the signal input period and measure a dutypulse is not enought to compute the PWM value.
Aboutthe
waclawek.jan
suggestion: is not simple matter to switch between channelstoget both the input PWM : if I do it automatically in ISR, and onechannel suddenly stop to supply
PWMsignal, the switch is stuck on this 'unavailable' signal waiting forISR call...
Ishould use a timer-driven to switch betwen channels measure but Ishould make
assumptinon the minimum frequency supplied to get at least 1 measure...
Not simple to overcome this 'nearly' independent channels...2014-04-24 08:23 AM
Each timer has a single counting element (time base), there is a latch for each channel (time stamp).
You can time-stamp the events, and compute delta measurements, I'm not sure how this gets to be materially different from what PWM Input mode achieves with a little more software effort, and interrupt loading. ie if you can use PWM Input Capture mode now for one signal, you can use Input Capture for two signals.2014-04-24 09:22 AM
2014-04-24 10:24 AM
Service both edges, read the time-stamp in the CCRx, check the GPIO, and use that and historic measurements from prior service of the channel. Compute rising edge to rising edge period, compute rising edge to falling edge.
2014-04-30 03:18 AM
Hiall, I have followed the useful suggestion and I have donesome work and test
tobuild a input capture, both edges, to realize the PWM inputmeasurement, without
triggerinput.
Ifirst try with each single edge, rise and fall, to test thetimer hardware behaviour
onthe configuration used : I could get the period correctly,without Overcapture error,
asexpected.
But,When I have changed only the CCER register to select bothedges, I couldn't be able
toget properly the falling edge ISR ( I think that this wasthe failure I experienced) , because
Igot Overcapture errors and the falling edge counter was not in therange expected .
Istill got rise edge counter correctly, because the periodmeasurement, based on rise edges, was OK .
I'llgive you the time stamp value of TIM9 register as shown by my KEILuVISION v5.x
peripheraldebugging view:
SMCR = 0x00CR1 = 0x81DIER = 0x02CCRM1 = 0x31EGR = 0x00CCER = 0x0Bmaybe I missed something ... ( I hope )HAS ANYONE EVER USED TIM9/12 IN INPUT CAPTURE FOR BOTH EDGES?..any suggestion will be appreciatedthanks2014-04-30 03:45 AM
I make some excuse on the text 'shrinked' above: I have done cut/paste of the text
from an external editor, other than the forum editor, because some time the page reports errors in sending the form and and crashes, loosing the text filled up .. bye2014-04-30 03:51 AM
The falling edge is apparently too close to the rising edge.
This is the caveat of the single-channel measurement: the edges can't be too close to each other. Clive has warned you in https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/DispForm.aspx?ID=41119&RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fstm32f40x%20discovery%20TIM9%20and%20TIM12%20PWM%20input%20capture : ''Provided the speed isn't too high
...'' Don't have unrealistic expectations and if you can't use either this nor the ''one-at-a-time'' method, you have to rewire the board. JW2014-04-30 07:17 AM
Hi,
I am testing with a 50% duty cycle and a period of 500uSec, with a clock timer with no prescaler value. I don't think the two edges are too close... but maybe I don't understand the warning you gave me.Now, I am toggling rise to fall edge and vice-versa, during ISR . I have no Overcapture, the ISR get the CCRx counter value and saves it for PWM computation, but the falling edge seem to get a CCRx value not updated... I am working on this issue. bye2014-05-10 12:55 AM
Hi,
I made some further test on switching the input channel, (using TIM1 to trig the switching time). I could measure the two PWM channel, but, when I supply both inputs I was only able to get only one correct channel : the start-time configuration one. The other was instable: if I disconnect the other input signal, the measure was correct. As info, when I got the previous result, among the TIM pwm channel configuration, I add a full peripheral pin reconfiguration: set the peripheral input pin unused as general purpose output, no-pullup-pulldown, open drain... No useful results. I tried also to insert a peripheral reset between input channel reconfiguration, but I was no more able to get valid measure for any channels. About reset: What is the correct procedure to reset a TIM peripheral? (I tried to set/reset even with delay in between ) the I mean the time and sequence to apply and remove the reset signal to the peripheral reset register, and if there are further Things to do to put the peripheral in start-up condition and fully reconfigurable... Do you ever experiment peripheral reset and reconfiguration issue? thank you