cancel
Showing results for 
Search instead for 
Did you mean: 

Quadrature encoder on STM32F429 discovery?

vasilevskialeksandar
Associate III
Posted on October 15, 2014 at 09:26

Hi,

I have working code on STM32F407 discovery board and would like to port it to discovery board based on STM32F429.

If I set GPIO_Mode_IN on STM32F429 I can see nice shaped signals from encoder on input pins PA1 and PA5. When I set GPIO_Mode_AF pins seems to be driven low from STM32F429 side.

AF is set to TIM2 with:   

   GPIO_PinAFConfig(GPIOA,GPIO_Pin_5,GPIO_AF_TIM2);

   GPIO_PinAFConfig(GPIOA,GPIO_Pin_1,GPIO_AF_TIM2);

Code for timer setting is same for both STM32F407 and STM32F429:

    TIM_TimeBaseStructure.TIM_Prescaler = 0x00; 

    TIM_TimeBaseStructure.TIM_Period = 65536; //max resolution

    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV4;//divide by clock by one

    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;// count up 

    TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

    TIM_EncoderInterfaceConfig(TIM2, TIM_EncoderMode_TI12,  TIM_ICPolarity_Falling, TIM_ICPolarity_Rising);

    TIM_ICStructInit(&TIM_ICInitStructure);

    TIM_ICInitStructure.TIM_ICFilter = 0;//ICx_FILTER;

    TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;

    TIM_ICInit(TIM2, &TIM_ICInitStructure);

    TIM2->CNT = 0;

    TIM_Cmd(TIM2, ENABLE);//enable encoder

Any ideas what can be wrong or differences between 32F407 and 32F429 that can trigger this problem?

Regards,

Aleksandar

#quadrature-encoder-stm32f429
3 REPLIES 3
Amel NASRI
ST Employee
Posted on October 15, 2014 at 10:31

Hi Aleksander,

There are 2 axes for checks:

1- Hardware side: review differences between both boards that may impact your application.

2- Software side: if you are enabling alternate functions on pins PA1 & PA5 after enabling TIM2 clock please try to do the inverse & check again. I am interested to know results.

-Mayla-

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.

Posted on October 15, 2014 at 12:29

   GPIO_PinAFConfig(GPIOA,GPIO_PinSource5,GPIO_AF_TIM2);

   GPIO_PinAFConfig(GPIOA,GPIO_PinSource1,GPIO_AF_TIM2);
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
vasilevskialeksandar
Associate III
Posted on October 15, 2014 at 12:58

Thanks!

I made mistake during porting. After all both macros are really similar.

BR,

Aleksandar