From 7f251e1380885d9a376310053c532412ea5a5ba1 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sat, 14 Oct 2017 19:33:41 -0300 Subject: [PATCH 1/7] Additional changes for 48 kHz --- CWIdTX.cpp | 8 ++++---- DMRDMORX.h | 2 +- DMRSlotRX.cpp | 6 +++--- DMRSlotRX.h | 2 +- IO.cpp | 6 +++--- SerialPort.cpp | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CWIdTX.cpp b/CWIdTX.cpp index 189e774..36784db 100644 --- a/CWIdTX.cpp +++ b/CWIdTX.cpp @@ -22,12 +22,12 @@ #include "CWIdTX.h" q15_t TONE[] = { - 0, 518, 1000, 1414, 1732, 1932, 2000, 1932, 1732, 1414, 1000, 518, 0, -518, -1000, -1414, -1732, -1932, -2000, -1932, -1732, -1414, -1000, -518}; - + 0, 261, 518, 765, 1000, 1218, 1414, 1587, 1732, 1848, 1932, 1983, 2000, 1983, 1932, 1848, 1732, 1587, 1414, 1218, 1000, 765, 518, 261, 0, -261, -518, -765, -1000, -1218, -1414, + -1587, -1732, -1848, -1932, -1983, -2000, -1983, -1932, -1848, -1732, -1587, -1414, -1218, -1000, -765, -518, -261}; q15_t SILENCE[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint8_t CYCLE_LENGTH = 24U; +const uint8_t CYCLE_LENGTH = 48U; const uint8_t DOT_LENGTH = 50U; diff --git a/DMRDMORX.h b/DMRDMORX.h index 6952fd4..344ffa2 100644 --- a/DMRDMORX.h +++ b/DMRDMORX.h @@ -22,7 +22,7 @@ #include "Config.h" #include "DMRDefines.h" -const uint16_t DMO_BUFFER_LENGTH_SAMPLES = 1440U; // 60ms at 24 kHz +const uint16_t DMO_BUFFER_LENGTH_SAMPLES = 2880U; // 60ms at 48 kHz enum DMORX_STATE { DMORXS_NONE, diff --git a/DMRSlotRX.cpp b/DMRSlotRX.cpp index 0d34560..2e906b1 100644 --- a/DMRSlotRX.cpp +++ b/DMRSlotRX.cpp @@ -22,8 +22,8 @@ #include "DMRSlotType.h" #include "Utils.h" -const uint16_t SCAN_START = 400U; -const uint16_t SCAN_END = 490U; +const uint16_t SCAN_START = 790U; +const uint16_t SCAN_END = 920U; const q15_t SCALING_FACTOR = 19505; // Q15(0.60) @@ -97,7 +97,7 @@ bool CDMRSlotRX::processSample(q15_t sample, uint16_t rssi) return m_state != DMRRXS_NONE; // Ensure that the buffer doesn't overflow - if (m_dataPtr > m_endPtr || m_dataPtr >= 900U) + if (m_dataPtr > m_endPtr || m_dataPtr >= 1900U) return m_state != DMRRXS_NONE; m_buffer[m_dataPtr] = sample; diff --git a/DMRSlotRX.h b/DMRSlotRX.h index a47cc73..e57e4f3 100644 --- a/DMRSlotRX.h +++ b/DMRSlotRX.h @@ -44,7 +44,7 @@ public: private: bool m_slot; uint32_t m_bitBuffer[DMR_RADIO_SYMBOL_LENGTH]; - q15_t m_buffer[900U]; + q15_t m_buffer[1900U]; uint16_t m_bitPtr; uint16_t m_dataPtr; uint16_t m_syncPtr; diff --git a/IO.cpp b/IO.cpp index 474d5eb..a6e1eec 100644 --- a/IO.cpp +++ b/IO.cpp @@ -167,7 +167,7 @@ void CIO::process() m_ledCount++; if (m_started) { // Two seconds timeout - if (m_watchdog >= 48000U) { + if (m_watchdog >= 96000U) { if (m_modemState == STATE_DSTAR || m_modemState == STATE_DMR || m_modemState == STATE_YSF) { if (m_modemState == STATE_DMR && m_tx) dmrTX.setStart(false); @@ -178,13 +178,13 @@ void CIO::process() m_watchdog = 0U; } - if (m_ledCount >= 24000U) { + if (m_ledCount >= 48000U) { m_ledCount = 0U; m_ledValue = !m_ledValue; setLEDInt(m_ledValue); } } else { - if (m_ledCount >= 240000U) { + if (m_ledCount >= 480000U) { m_ledCount = 0U; m_ledValue = !m_ledValue; setLEDInt(m_ledValue); diff --git a/SerialPort.cpp b/SerialPort.cpp index b707c36..5b38e4a 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -73,9 +73,9 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U; #if defined(EXTERNAL_OSC) -#define DESCRIPTION "MMDVM 20170501 TCXO (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" +#define DESCRIPTION "MMDVM 20170501 TCXO 48kHz (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" #else -#define DESCRIPTION "MMDVM 20170501 (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" +#define DESCRIPTION "MMDVM 20170501 48kHz (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" #endif #if defined(GITVERSION) From 2f766ffeeada1697885bd3ae4800bdad4e036b0d Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sat, 14 Oct 2017 21:17:55 -0300 Subject: [PATCH 2/7] Increase DMR rssi buffer size --- DMRSlotRX.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DMRSlotRX.h b/DMRSlotRX.h index e57e4f3..f75fae7 100644 --- a/DMRSlotRX.h +++ b/DMRSlotRX.h @@ -62,7 +62,7 @@ private: DMRRX_STATE m_state; uint8_t m_n; uint8_t m_type; - uint16_t m_rssi[900U]; + uint16_t m_rssi[1900U]; void correlateSync(bool first); void samplesToBits(uint16_t start, uint8_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold); From b0f8cb8908ea4bc1a5def9e47dda334720d96016 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sat, 14 Oct 2017 23:28:25 -0300 Subject: [PATCH 3/7] Fix D-Star for 48 kHz --- DStarRX.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DStarRX.cpp b/DStarRX.cpp index 4def275..b7a5676 100644 --- a/DStarRX.cpp +++ b/DStarRX.cpp @@ -381,10 +381,10 @@ void CDStarRX::processHeader(q15_t sample) m_frameCount = 0U; m_dataPtr = 0U; - m_startPtr = 476U; - m_syncPtr = 471U; - m_maxSyncPtr = 472U; - m_minSyncPtr = 470U; + m_startPtr = 952U; + m_syncPtr = 942U; + m_maxSyncPtr = 944U; + m_minSyncPtr = 940U; DEBUG5("DStarRX: calc start/sync/max/min", m_startPtr, m_syncPtr, m_maxSyncPtr, m_minSyncPtr); From 6192d75c4afe0ae4565c9e2f68629eea252ba935 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sun, 15 Oct 2017 11:27:45 -0300 Subject: [PATCH 4/7] Removing 48 kHz string in description --- SerialPort.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SerialPort.cpp b/SerialPort.cpp index 5b38e4a..b707c36 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -73,9 +73,9 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U; #if defined(EXTERNAL_OSC) -#define DESCRIPTION "MMDVM 20170501 TCXO 48kHz (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" +#define DESCRIPTION "MMDVM 20170501 TCXO (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" #else -#define DESCRIPTION "MMDVM 20170501 48kHz (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" +#define DESCRIPTION "MMDVM 20170501 (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" #endif #if defined(GITVERSION) From b1dceec4441ae77ba6b4a970bbd2f624ef32621f Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sun, 15 Oct 2017 12:16:19 -0300 Subject: [PATCH 5/7] Updating serial port watchdog for 48 kHz --- SerialPort.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPort.cpp b/SerialPort.cpp index b707c36..082ceea 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -668,7 +668,7 @@ void CSerialPort::process() } } - if (io.getWatchdog() >= 48000U) { + if (io.getWatchdog() >= 96000U) { m_ptr = 0U; m_len = 0U; } From 4ac7d63af9ab80e33ed2cb315978aff4989c7bcb Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sun, 15 Oct 2017 13:30:12 -0300 Subject: [PATCH 6/7] Adding 48 kHz in description (but shorting string) --- SerialPort.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SerialPort.cpp b/SerialPort.cpp index 082ceea..6c1c06f 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -73,9 +73,9 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U; #if defined(EXTERNAL_OSC) -#define DESCRIPTION "MMDVM 20170501 TCXO (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" +#define DESCRIPTION "MMDVM 20170501 TCXO 48kHz (D-Star/DMR/YSF/P25/RSSI/CW Id)" #else -#define DESCRIPTION "MMDVM 20170501 (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" +#define DESCRIPTION "MMDVM 20170501 48kHz (D-Star/DMR/YSF/P25/RSSI/CW Id)" #endif #if defined(GITVERSION) From 942b9365a69d0f670cab3dc6b544b7a8124dc278 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sun, 15 Oct 2017 17:23:21 -0300 Subject: [PATCH 7/7] 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 6ca8102..d90ed40 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);