From 2279162db50b40d6f5c1e4526c60338e6dfd8b4d Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sun, 15 Oct 2017 17:32:24 -0300 Subject: [PATCH] Better way for sampling frequency calculation for MMDVM-Pi --- IOSTM.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/IOSTM.cpp b/IOSTM.cpp index 6e25931..047b6d9 100644 --- a/IOSTM.cpp +++ b/IOSTM.cpp @@ -642,12 +642,13 @@ void CIO::startInt() // TIM2 output frequency #if defined(EXTERNAL_OSC) && !defined(STM32F4_PI) timerInitStructure.TIM_Prescaler = (uint16_t) ((EXTERNAL_OSC/(2*SAMP_FREQ)) - 1); + timerInitStructure.TIM_Period = 1; #else - timerInitStructure.TIM_Prescaler = (uint16_t) ((SystemCoreClock/(4*SAMP_FREQ)) - 1); + timerInitStructure.TIM_Prescaler = (uint16_t) ((SystemCoreClock/(6*SAMP_FREQ)) - 1); + timerInitStructure.TIM_Period = 2; #endif timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up; - timerInitStructure.TIM_Period = 1; timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; timerInitStructure.TIM_RepetitionCounter = 0; TIM_TimeBaseInit(TIM2, &timerInitStructure);