Hallo zusammen, Bin seit einiger Zeit dabei einen Input Capture zu programmieren. Leider stimmt etwas bei meiner Definition nicht, da es die Flanke nicht erkennt. Das Eingangssignal ist ein Rechtecksignal mit der Frequenz von 50Hz. Dies ist vorhanden und auch am richtigen Pin (mehrmals kontrolliert). Könntet Ihr meine Definition anschauen und mir helfen dies lauffähig zu kriegen?? Hier ist Noch der Code: // TIM4 for phase detector: input capture on pin 60 PD13 TIM4_CH2 // TIM4 I/O are remapped to pins PD12-5 , refer to RM0008 p 157, 173, 180 AFIO->MAPR |= AFIO_MAPR_TIM4_REMAP; // TIM4_CR1 control register 1: direction upcounter -> DIR = 0 default, counter enable CEN = 1 done at end of configuration // TIM4_CR2 control register 2: default // TIM4_SMCR slave mode control register: SMS = 000 default, slave mode disabled -> TIM4 clocked by internal clock // TIM4_DIER DMA/int enable register: CCP2IE = 1 cap/com int enable in isr // TIM4_SR status register: CC2IF = 0 clear cap/com int flag in isr // TIM4_EGR event generation register: // TIM4_CCMR1 cap/com mode register 1: IC2F = 0010 input filter 4 clocks, // IC2PSC = 00 default no input cap prescaler, CC2S = 01 CC2 is input and IC2 mapped to TI2, TIM4->CCMR1 |= ( TIM_CCMR1_IC2F_1 | TIM_CCMR1_CC2S_1 ); // TIM4_CCMR2 cap/com mode register 2: // TIM4_CCER cap/com enable register: CC2P = 1: polarity falling edge, CC2E = 1 cap/comp enable in ISR TIM4->CCER |= TIM_CCER_CC2P; // TIM4_CNT counter value: // TIM4_PSC prescaler: PSC = 0x0000 -> 1:1 prescaler TIM4->PSC = (uint16_t)0x0000; // TIM4_ARR auto reload register =0xffff for up counting from 0 to ffff (must be set!=0 otherwise the timer is blocked) TIM4->ARR = (uint16_t)0xFFFF; // TIM4_CCR1-4 capture compare register: // TIM4_DCR DMA control register: // TIM4_DMAR DMA address for full transfer TIM4->CR1 |= TIM_CR1_CEN; // counter enable Danke schon mal im voraus. Gruss
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.