added filtering to encoder inputs
diff --git a/bbb_cape/src/cape/encoder.c b/bbb_cape/src/cape/encoder.c
index 93868fb..ad59248 100644
--- a/bbb_cape/src/cape/encoder.c
+++ b/bbb_cape/src/cape/encoder.c
@@ -109,9 +109,13 @@
TIM_CR1_URS /* don't generate spurious update interrupts that
might be shared with other timers */;
timer->SMCR = 3; // 4x quadrature encoder mode
+ timer->CCER = 0;
timer->CCMR1 =
TIM_CCMR1_CC2S_0 | /* input pin 2 -> timer input 2 */
- TIM_CCMR1_CC1S_0; /* input pin 1 -> timer input 1 */
+ TIM_CCMR1_CC1S_0 | /* input pin 1 -> timer input 1 */
+ (3 << 4) |
+ (3 << 12);
+ timer->PSC = 0;
timer->EGR = TIM_EGR_UG;
timer->CR1 |= TIM_CR1_CEN;
}
diff --git a/bbb_cape/src/cape/robot_comp.c b/bbb_cape/src/cape/robot_comp.c
index ddd3f2d..57e3d66 100644
--- a/bbb_cape/src/cape/robot_comp.c
+++ b/bbb_cape/src/cape/robot_comp.c
@@ -102,7 +102,7 @@
void robot_init(void) {
gpio_setup_alt(GPIOB, 9, 3);
RCC->APB2ENR |= RCC_APB2ENR_TIM11EN;
- TIM11->CR1 = 0;
+ TIM11->CR1 = TIM_CR1_URS;
TIM11->SMCR = 5 << 4 /* TI1 */ |
6 << 0 /* start on rising edge */;
TIM11->DIER = TIM_DIER_CC1IE;