Hallo Ich möchte einen Quadratur-Encoder an Timer2 anschliessen um die Position zu bestimmen. Bei Timer3 hat es geklappt, da dieser aber 16Bit ist habe ich auf Timer2 (32Bit) gewechselt. Jetzt habe ich aber TIM2_CH1 (PA5) und TIM2_CH4 (PA3) frei. Geht das irgendwie? Normalerweise muss ich CH1 und CH2 nehmen, CH2 benötige ich aber für Ethernet und kann nicht verwendet weren. Die Initialisierung vom Encoder Modul: void Position_Encoder_Config(void) //für Position von Encoder { 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_5 | GPIO_Pin_3; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, 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, Encoder_Position_Default); //set the Timer to the default init value (middle) /* TIM2 counter enable */ TIM_Cmd(TIM2, ENABLE); } Danke
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.