cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 Timer reampping

dominik
Senior
Posted on July 11, 2014 at 11:17

Hello

I'm using the Timer2 as Encoder Position Timer:

void Encoder_Config(void)

{

    GPIO_InitTypeDef GPIO_InitStructure;

    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_5;

    GPIO_Init(GPIOA, &GPIO_InitStructure);

    GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_TIM2);

    GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_TIM2);

    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;

    TIM_TimeBaseStructure.TIM_Period = 0xffff;

    TIM_TimeBaseStructure.TIM_Prescaler = 0;

    TIM_TimeBaseStructure.TIM_ClockDivision = 0;

    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

    TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

    /* Configure the timer */

    TIM_EncoderInterfaceConfig(TIM2, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Falling);

    TIM_SetCounter (TIM2, (uint32_t) Encoder_Position_Default);      //set the Timer to the default init value (middle)

    /* TIM2 counter enable */

    TIM_Cmd(TIM2, ENABLE);

    TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);

}

Timer 4 I use to measure a frequency on a second Encoder.

This is working great.

But in a different seeting I have just 1 Encoder connected to the Timer4 to measure the frequency, works aswell. But I need to get the EncoderPositionMode fro the same Encoder Signals which ones are connected to Timer2. Can I remap the Signals from Timer4 to Timer2 to measure the frequency with Timer4 and the Position with Timer2 without a connected Encoder to the Timer2? Is there an example?

Thanks and Regards, Dominik
1 REPLY 1
Posted on July 11, 2014 at 16:47

If I understand the question correctly, the answer is no.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..