cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 CubeMX Timer 2 in Gated mode with capture on chanale 1

Valery Har
Associate II
Posted on December 25, 2016 at 20:17

I

want

using STM32F4

07

Discovery with CubeMX to initialize of Timer 2 in Gated mode with capture on Channel 1. In manual RM090 Rev 13 on page 618 and 619 there is setting

to

work in this mode. But if you use CubeMX, this settings could not be implemented. I mean Tim2_SMCR register and bits SMS=101 with TS=101 (SMS = Gated mode, TS= Filtered Timer input 1 (TI1FP1)). Because of gray field for TI1FP1 in CubeMX (position Trigered Source TI1FP1 is grayed, but active TI1FP2). CubeMX explain this : �An active Slave mode should be select first. This option may be unavailable if Channel 1 is used�. Where is mistake in RM090 or CubeMX?

Ok. Lets set Triger Source as TI1FP2 and try to use Timer 5 in the same mode as Timer 2. And you will see another grayed and red fields in options, that mean - you couldn�t use Timer 5 in so manner as Timer 2. Why? Timer 2 and Timer 5 are not fully independent? They use the same hardware?

#stm32-timer #stm32f4
4 REPLIES 4
Amel NASRI
ST Employee
Posted on December 26, 2016 at 17:18

Hi

har.valery

‌,

1- In TIM2 configuration, TI1FP1 is grayed because channel 1 is already configured in 'Input Capture direct mode'. If you disable Channel 1, you will be able to select TI1FP1 as trigger source.

2- In TIM5 configuration:

  • TI1FP1 is red because there is a conflict in using PA0 (wakeup button). If you disable GPIO_EXTI0 on PA0 and select TIM5_CH1 instead, then TI1FP1 will be available as trigger source for TIM5.
  • TI2FP2 is red because there is a conflict with TIM2_CH2 (when you selected TI2FP2) on PA1.

So you have to look for a new mapping of pins to avoid these conflicts.

-Amel-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Valery Har
Associate II
Posted on December 27, 2016 at 11:27

Hi Amel.

Thank you for answer. As I understand you content the primer in RM090 Rev 13 is not correct. As for pin PA0. I have change it connection and can select Channel 1 for capture signal of Timer 5. But still I couldn’t use TI1FP2 as Trigger Source for Tim 5. And reason of that is “Conflict with TIM2�. It has used that signal (TI1FP2) for it’s own triggering. That means - Signal TI1FP1 and TI1FP2 are really the one in all timers hardware. Are you sure? Are you hardware developer of STM32F407 chip? If that right we cannot use Timer 2 and Time 5 in one mode never. It very bad news for developers.

Posted on December 27, 2016 at 12:19

Hi Valery,

It seems that my explanation wasn't enough understandable.

There is no error in RM0090.

You have to refer to relevant datasheet of your product to know the correct combination of pins.

If you start from the chip STM32F407 (not the discovery board), to generate your project you will see less conflicts.

Now, look at

http://www.st.com/content/ccc/resource/technical/document/datasheet/ef/92/76/6d/bb/c2/4f/f7/DM00037051.pdf/files/DM00037051.pdf/jcr:content/translations/en.DM00037051.pdf

and based on CubeMX interface:

- to select TI2FP2 as trigger source for TIM2 or TIM5, you have to select correct pin for the channel 2.

- both TIM2_CH2 and TIM5_CH2 are mapped on the same pin PA1. This is source of conflict.

If you want to discard this conflict, you have to set a new mapping for TIM2_CH2 (Only choice is PB3 on LQFP100 package) and keep PA1 for TIM5_CH2.

Hope it is more understandable now.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Valery Har
Associate II
Posted on December 28, 2016 at 12:40

Hi Amel,

Thank you for your patience and answer. I have resolved the problem with the independence of TIM2 and TIM5, just assigned a different input pins for timers. That is a good news? But still has one unclear question with Gated mode. As I wrote earlier in manual RM090 Rev 13 there is a primer to set register of timer for working in that regime. Hire is a brief settings of it for TIM2:

Register TIM2_CCMR1: CC1S=01 (CC1 channel is configured as input, IC1 is mapped on TI1).

Register TIM2_CCER: CC1P=1 (OC1 active low).

Register TIM2_SMCR: TS=101 (Filtered Timer input 1 (TI1FP1)), SMS-101 (Gated mode).

Well. In CubeMX I chuse next option:

Slave mode: Gated mode.

Trigger Source: Disable.

Clock source: Internal Clock.

Channel 1: Input Capture direct mode.

As you can see, that settings will set all bits in the same value as mentioned foregoing. But when you check Configuration tab in CubeMX you can see for Timer 2 a curious message: “Please select a Trigger Source in the Pinout view�. OK, lets try to select Trigger Source. For sorry there is only TI1FP2 active option TI1FP1 is dimmed. That means you have used one more input pin for TIM2 to work in Gated mode. But in RM090 Rev 13 has not one word about timer needs Trigger Source for working in Gated mode. May be you know why CubeMX wants a Trigger Source for Gated mode? And if it is right why TI1FP1 (the same pin for capture and for triggering) cannot be used for that? For example: UP front is used for triggering and DOWN front for capture signal.