diff --git a/TNC/Afsk1200Demodulator.cpp b/TNC/Afsk1200Demodulator.cpp index 2d4277d..a277063 100644 --- a/TNC/Afsk1200Demodulator.cpp +++ b/TNC/Afsk1200Demodulator.cpp @@ -198,9 +198,9 @@ uint32_t Afsk1200Demodulator::readBatteryLevel() // Order of operations is important to avoid underflow. vbat *= 6600; - vbat /= (vrefint + 1); + vbat /= (VREF + 1); - uint32_t vref = (vrefint * 3300) + (VREF / 2) / VREF; + uint32_t vref = ((vrefint * 3300) + (VREF / 2)) / VREF; INFO("Vref = %lumV", vref) INFO("Vbat = %lumV", vbat); diff --git a/TNC/Fsk9600Demodulator.cpp b/TNC/Fsk9600Demodulator.cpp index e15cd2b..18e198a 100644 --- a/TNC/Fsk9600Demodulator.cpp +++ b/TNC/Fsk9600Demodulator.cpp @@ -158,9 +158,9 @@ uint32_t Fsk9600Demodulator::readBatteryLevel() // Order of operations is important to avoid underflow. vbat *= 6600; - vbat /= (vrefint + 1); + vbat /= (VREF + 1); - uint32_t vref = (vrefint * 3300) + (VREF / 2) / VREF; + uint32_t vref = ((vrefint * 3300) + (VREF / 2)) / VREF; INFO("Vref = %lumV", vref) INFO("Vbat = %lumV", vbat); diff --git a/TNC/Fsk9600Demodulator.hpp b/TNC/Fsk9600Demodulator.hpp index 2283cc6..4a57f5d 100644 --- a/TNC/Fsk9600Demodulator.hpp +++ b/TNC/Fsk9600Demodulator.hpp @@ -32,7 +32,7 @@ struct Fsk9600Demodulator : IDemodulator static_assert(audio::ADC_BUFFER_SIZE >= ADC_BLOCK_SIZE); static constexpr uint32_t SAMPLE_RATE = 192000; - static constexpr uint16_t VREF = 16383; + static constexpr uint16_t VREF = 4095; using bpf_coeffs_type = std::array; using bpf_bank_type = std::array;