cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F405: Read 100% duty cycle

miriarte
Associate II
Posted on September 27, 2012 at 11:21

I am using STM32F405 in an application and in order to start working with the PWM module I have to check that I read a 100% duty cycle on one channel input.

I've been reading documentation, but it seems that input capture mode only works if there are transitions on the signal. This is not my case; I need to check that I read 100% duty cycle from the beginnning (input signal always to '1').

How can I do this? How should I configure the timer input?

#stm32f405 #poorly-framed-question
6 REPLIES 6
Posted on September 27, 2012 at 14:40

A falling-edge triggered interrupt, maybe?

Posted on September 27, 2012 at 16:00

Yeah, going to be a real bugger detecting transitions when there are none.

If you want to check if a pin is DC, then read the IO.

Does the signal transition EVER? Like what's the condition where it's NOT in the 100%/DC condition, maybe you can check for THAT instead. As the prior poster suggested when you get a 1->0 drop generate an interrupt.

What's the frequency of the other channels.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
miriarte
Associate II
Posted on September 27, 2012 at 16:23

Ok, it seems that I have to explain it more...

We have a system with 10MCBs (mounted Circuit Boards) each one with a STM32F405. The 10 MCBs are connected between them in a series connection. The output connector of the 1st one, is the input of the 2nd one; the output of the 2nd one is the input of the 3rd one...All of them must have the same HW and SW. 

We need to differentiate between the 1st MCB (the first uC) and the rest of them. To do this, we have connected a pin in the entrance connector to '+VDD'. In the next MCBs (2,3,4, etc) this pin is connected to the output of the previous one. This pin is routed to the PWM input.

For the 1st MCB this pin is always '1'; and for the rest of MCBs this pin is a PWM input. I need to read a 100% duty cycle in the fist one to check that that is the FIRST MCB, and read a duty cycle in the rest of MCBs. But in the same pin and with the same HW/SW.

So...I need to read a 100% duty cycle in a PWM input...is it possible???

Posted on September 27, 2012 at 16:48

Perhaps you could observe if TIM_IT_CCx does not get asserted between TIM_IT_Update periods?

Perhaps a better method of detecting the position in a daisy change would be to use a flip-flop in each PCB which halved the input frequency, and measure that.

Or count pin transitions over a prescribed interval.

Another would be to use a 4-bit ID passed down the chain.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
miriarte
Associate II
Posted on September 27, 2012 at 18:28

Thanks! I will try with the flip-flops.

Posted on September 28, 2012 at 04:47

Sorry, but I don't understand this fixation with a PWM input and adding flip-flops doesn't make any more sense, either.  Seriously?  You've got edge-detecting GPIO's on your device, right?  Just step away from the soldering iron and think a little...

At startup, each board in the chain drives low its output (which should already have an external pulldown on it), reads its input, starts a timer, and counts edges received from its upstream neighbor.  Read the input again at the timer expiry.  All boards except the first then just sit and wait for pulses from their upstream neighbor.  The first board knows it's first because it has a constant high level at its input at both ends of the timer interval.  This board waits a little while then pops off a single pulse to its downstream neighbor, waits a little while and repeats the single pulse, and so on.  The first board's neighbor gets a single edge (within an interval started by that edge), so it then (when the time interval is complete) pops off two pulses to its downstream neighbor, and so on.  An increasing number of pulses ripples down the chain as each board learns its position.

Assuming all the boards power up/reset at roughly the same time, the first node should only have to repeat it's task (wait, issue one pulse, goto wait) a fixed number of times (I'd guess to start out with 2X the number of boards) before all the boards know their position.  The whole process should take roughly (number of boards) X (time interval started by the first received pulse) X (number of iterations done by the first board).

Maybe you should have just strung them together with a UART signal instead and skipped all that PWM silliness (and even my silliness described above).