2555 views|2 replies

18

Posts

0

Resources
The OP
 

103TIM3 ch1, ch2 remapping to PC6, PC7 failed [Copy link]

void ENC_Init_3(void)
{
        GPIO_InitTypeDef  GPIO_InitStructure;
        TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
        TIM_ICInitTypeDef TIM_ICInitStructure;
               
        RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, ENABLE);
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
       
        GPIO_PinRemapConfig(GPIO_FullRemap_TIM3, ENABLE);        


       
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100M
        GPIO_Init(GPIOC, &GPIO_InitStructure);
       
       
        TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);

        TIM_TimeBaseStructure.TIM_Prescaler = 0x0; // No prescaling
        TIM_TimeBaseStructure.TIM_Period = 65000;  //éèò×′óêyéT
        TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
        TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;   
        TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);

//  TIM_EncoderInterfaceConfig(TIM3, TIM_EncoderMode_TI1, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
        TIM_EncoderInterfaceConfig(TIM3, TIM_EncoderMode_TI12, TIM_ICPolarity_Falling, TIM_ICPolarity_Falling);
        TIM_ICStructInit(&TIM_ICInitStructure);
        TIM_ICInitStructure.TIM_ICFilter = 0;
        TIM_ICInit(TIM3, &TIM_ICInitStructure);

  // Clear all pending interrupts
        TIM_ClearFlag(TIM3, TIM_FLAG_Update);
        TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);

        TIM_Cmd(TIM3, ENABLE);
}

This post is from stm32/stm8

Latest reply

Agree with the above   Details Published on 2018-4-20 13:22
 

18

Posts

0

Resources
2
 
Change RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, ENABLE); to RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE)
This post is from stm32/stm8
 
 

4005

Posts

0

Resources
3
 
Agree with the above

This post is from stm32/stm8
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list