cancel
Showing results for 
Search instead for 
Did you mean: 

Pwm input mode F401RE

Marco Perciavalle
Associate II
Posted on October 30, 2017 at 11:09

Hi, i have a problem about pwm input mode for f401re board. Forse my purpose, I use cubemx and set Tim 9 slave controller in reset mode, TI1FP1 ad trigger source, Channel 1 in input capture direct mode and Channel 2 in input capture indirect mode, as It is written in ref manual. Then I thick 'internal clock', choose an ARR value and prescaler values compatible with my test signal to mesure and generate the code.

On IAR, I only enable timer input capture mode using 'HAL_TIM_IC_Start(&htim9,TIM_CHANNEL_ALL' function. What i see is that the counter Tim 9 works, CNT is continuosly updated, but Tim9_ccr1 and tim9_ccr2 always remain at 0 values despite the test pwm signal has the right frequency according to counter's range. It seems the board doesn t recognize signal's edges. On reference manual is written that ccrx values should not reset despite of the reset mode. So, is there anything else to do?

Thanks for all the answer. Best regards.

#stm32-f4 #pwm #input-capture-mode

Note: this post was migrated and contained many threaded conversations, some content may be missing.
11 REPLIES 11
Posted on October 30, 2017 at 11:15

GPIO for given pin set properly?

Read out related GPIO and TIM registers' content and post.

JW

Posted on October 31, 2017 at 14:41

Hi, thanks a lot for the answer.

Here are posted screens about TIM9 and GPIOA.

In this particular project the same board generate also PWM signal, using another timer (TIM1). If I use two different board, the result is the same. PA2 is a pin linked to TIM9, used to acquire information from a PWM signal. PA8 is linked to TIM1 which generates PWM signal. It seems that the generation has success. Otherwise, IDR8 is costant, but it changes.

0690X00000604BMQAY.jpg

GPIOA

0690X00000604BRQAY.jpg

TIM9

I notice that CC2IE and CC1IE are at 0 value. I modify it manually but the result is the same.

Posted on October 31, 2017 at 14:49

Neither channel's capture is enabled in CCER.

JW

Posted on October 31, 2017 at 15:30

I enable it but nothing. 

Should HAL function (HAL_TIM_IC_Start) set these registers automatically?

Posted on October 31, 2017 at 15:47

I enable it but nothing. 

Do you see GPIOA->IDR bit 2 to change in the debugger (in other words, are you sure there is valid input to PA2)?

You have set a relatively big prescaler on TIM9, are you sure the PWM input is slow enough?

If you don't set the reset mode (i.e. set TIM9_SMCR.SMS=0), do you see the values in TIM9_CCR1/CCR2 changing?

Should HAL function (HAL_TIM_IC_Start) set these registers automatically?

I don't and won't use Cube.

JW

Posted on October 31, 2017 at 16:19

Do you see GPIOA->IDR bit 2 to change in the debugger (in other words, are you sure there is valid input to PA2)?

You have set a relatively big prescaler on TIM9, are you sure the PWM input is slow enough? 

PWM signal is generated by TIM1 on the same board. The prescaler is the same and its ARR value is less then the TIM9's ARR value. However IDR2 doesn't change. I wired D1 (PA2) and D7 (PA8) which are input and output pins.

If you don't set the reset mode (i.e. set TIM9_SMCR.SMS=0), do you see the values in TIM9_CCR1/CCR2 changing?

No.

I don't and won't use Cube.

Maybe I should do it, too... 

Posted on October 31, 2017 at 17:09

Do you have an oscilloscope to check this, * directly * at the PA2 pin of the mcu? What board is this? Isn't there something else on PA2?

JW

Posted on November 01, 2017 at 12:42

I use ADC on the board and there is the correct swing from VDD to GND and viceversa on PA2.

Posted on November 01, 2017 at 20:17

That's more hummm.

PA2 is also TIM5_CH3. Can you please try to set it up in GPIO for AF2 for TIM5, set TIM5 to run (enable clock in RCC, ARR=0xFFFFFFFF, CR1.CEN=1), CH3 for straight capture (CCMR2.CC3S = 1, CCER.CC3E = 1) and observe CCR3?

JW