F429 Timer Encoder Event

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
maknoll
Posts: 1
Joined: Tue Aug 11, 2015 1:49 am

F429 Timer Encoder Event

Post by maknoll »

Hi,

i want to user the timer encoder interface of the F4. I already came up with init code, since the GPT driver does not directly support this.

Code: Select all

void setup_encoder(void) {
    palSetPadMode(GPIOD,12, PAL_MODE_ALTERNATE(2));
    palSetPadMode(GPIOD,13, PAL_MODE_ALTERNATE(2));
   
    rccEnableTIM4(FALSE);
    rccResetTIM4();
   
   
    STM32_TIM4->SMCR = 3;          // Encoder mode 3
    STM32_TIM4->CCER = 0;          // rising edge polarity
    STM32_TIM4->ARR = 0xFFFF;      // count from 0-ARR or ARR-0
    STM32_TIM4->CCMR1 = 0xC1C1;    // f_DTS/16, N=8, IC1->TI1, IC2->TI2
    STM32_TIM4->CNT = 0;           // Initialize counter
    STM32_TIM4->EGR = 1;           // Generate an update event
    STM32_TIM4->CR1 = 1;           // Enable the counter
}


The nice stackoverflow guy i got part of the code from already generates a update event. I want to use this Event/Interrupt to handle the rotations.

What would be the chibios way to do this? I have seen that in the GPT Driver i can configure a callback. Can i use this even if a configure the timer manually?
Or can i somehow use the event system for this?

Context is a Rotary Encoder as a UI input (ugfx). I am new to ChibiOS.

thx :)
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: F429 Timer Encoder Event

Post by Giovanni »

ChibiOS does not support that mode currently.

There is a contributed driver for that: viewtopic.php?f=14&t=685

It would be nice to put it into the community repository.

Giovanni
Post Reply