From e3bb458580588aec8eb294db96e4f7e8f56e62ae Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 5 May 2018 11:57:13 +0200 Subject: Change firmware to fit Lyza TODO: Merge with original code, allow for compile-time switchj between Lyza and Olsndot. --- firmware/main.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'firmware') diff --git a/firmware/main.c b/firmware/main.c index 7bfa097..9391acd 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -138,11 +138,8 @@ int main(void) { | (2<MODER |= - (2<OTYPER |= GPIO_OTYPER_OT_6; /* LED outputs -> open drain */ @@ -151,9 +148,8 @@ int main(void) { (3<OSPEEDR |= - (3<AFR[0] |= @@ -163,9 +159,8 @@ int main(void) { | (0<AFR[1] |= - (2<AFR[0] |= - (2< 16MBd */ @@ -177,13 +172,15 @@ int main(void) { TIM1->PSC = 0; /* Do not prescale, resulting in a 30MHz timer frequency and 33.3ns timer step size. */ /* CH2 - clear/!MR, CH3 - strobe/STCP */ + TIM1->CCMR1 = (6<CCMR2 = (6<CCER |= TIM_CCER_CC3E | TIM_CCER_CC3NE | TIM_CCER_CC3P | TIM_CCER_CC3NP | TIM_CCER_CC4E; - TIM1->BDTR = TIM_BDTR_MOE | (1<CCER |= TIM_CCER_CC3E | TIM_CCER_CC2E | TIM_CCER_CC3P | TIM_CCER_CC4E; + TIM1->BDTR = TIM_BDTR_MOE; TIM1->DIER = TIM_DIER_UIE; /* Enable update (overrun) interrupt */ TIM1->ARR = 1; TIM1->CR1 |= TIM_CR1_CEN; - /* Trigger at the end of the longest bit cycle. This means this does not trigger in shorter bit cycles. */ + /* TIM1 CC channel 4 is used to trigger an ADC run at the end of the longest bit cycle. This is done by setting a + * value that is large enough to not trigger in shorter bit cycles. */ TIM1->CCR4 = timer_period_lookup[NBITS-1] - ADC_PRETRIGGER; /* Configure Timer 1 update (overrun) interrupt on NVIC. Used only for update (overrun) for strobe timing. */ -- cgit