AnsweredAssumed Answered

stm32f103 encoder mode with as5040

Question asked by karol.karol on Apr 26, 2015
Latest reply on Apr 28, 2015 by karol.karol
Hi, I have problem with encoder mode. AS5040 is in quadrature output. I use this code and it doesnt work, where is the problem?

void gpio_conf(void) {
    GPIO_InitTypeDef GPIO_InitStructure;
     
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 | RCC_APB2Periph_GPIOB, ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
 
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_Init(GPIOB, &GPIO_InitStructure);
}
 
void TIM1_Configuration(void) {
    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
 
    TIM_TimeBaseStructure.TIM_Prescaler = 0;
    TIM_TimeBaseStructure.TIM_Period = 65535;
    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
 
    TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
 
    TIM_EncoderInterfaceConfig(TIM1, TIM_EncoderMode_TI1, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
 
    TIM_Cmd(TIM1, ENABLE);
}

Outcomes