From 37080d99017cb918af2dc8ec1e1d9e94f5baf436 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 19 Dec 2016 15:27:52 +0000 Subject: [PATCH] Update to 48 kHz sample rate. --- CWIdTX.cpp | 7 ++++--- DMRDMORX.h | 2 +- DMRDMOTX.cpp | 24 ++++++++---------------- DMRDMOTX.h | 2 +- DMRDefines.h | 2 +- DMRSlotRX.cpp | 6 +++--- DMRSlotRX.h | 2 +- DMRTX.cpp | 24 ++++++++---------------- DMRTX.h | 2 +- DStarDefines.h | 2 +- DStarTX.cpp | 12 ++++++------ DStarTX.h | 2 +- IO.cpp | 26 +++++++++----------------- IO.h | 2 +- IODue.cpp | 8 ++++---- IOSTM.cpp | 2 +- IOTeensy.cpp | 8 ++++---- P25Defines.h | 2 +- P25TX.cpp | 26 +++++++++----------------- P25TX.h | 4 ++-- SerialPort.cpp | 4 ++-- YSFDefines.h | 2 +- YSFTX.cpp | 24 ++++++++---------------- YSFTX.h | 2 +- 24 files changed, 79 insertions(+), 118 deletions(-) diff --git a/CWIdTX.cpp b/CWIdTX.cpp index 0613772..ffe8ff5 100644 --- a/CWIdTX.cpp +++ b/CWIdTX.cpp @@ -24,12 +24,13 @@ #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 1049fd1..73b2545 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/DMRDMOTX.cpp b/DMRDMOTX.cpp index 3ba6830..ec29509 100644 --- a/DMRDMOTX.cpp +++ b/DMRDMOTX.cpp @@ -23,23 +23,15 @@ #include "Globals.h" #include "DMRSlotType.h" -#if defined(WIDE_C4FSK_FILTERS_TX) -// Generated using rcosdesign(0.2, 4, 5, 'sqrt') in MATLAB -static q15_t DMR_C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, - 11310, 7041, 2684, -775, -2724, -3060, -2158, -680, 688, 0}; -const uint16_t DMR_C4FSK_FILTER_LEN = 22U; -#else -// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB -static q15_t DMR_C4FSK_FILTER[] = {401, 104, -340, -731, -847, -553, 112, 909, 1472, 1450, 683, -675, -2144, -3040, -2706, -770, 2667, 6995, - 11237, 14331, 15464, 14331, 11237, 6995, 2667, -770, -2706, -3040, -2144, -675, 683, 1450, 1472, 909, 112, - -553, -847, -731, -340, 104, 401, 0}; +// Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB +static q15_t DMR_C4FSK_FILTER[] = {486, 39, -480, -1022, -1526, -1928, -2164, -2178, -1927, -1384, -548, 561, 1898, 3399, 4980, 6546, 7999, 9246, 10202, 10803, 11008, 10803, 10202, 9246, + 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0}; const uint16_t DMR_C4FSK_FILTER_LEN = 42U; -#endif -const q15_t DMR_LEVELA[] = { 640, 640 , 640, 640, 640}; -const q15_t DMR_LEVELB[] = { 213, 213, 213, 213, 213}; -const q15_t DMR_LEVELC[] = {-213, -213, -213, -213, -213}; -const q15_t DMR_LEVELD[] = {-640, -640, -640, -640, -640}; +const q15_t DMR_LEVELA[] = { 395, 395, 395, 395, 395, 395, 395, 395, 395, 395}; +const q15_t DMR_LEVELB[] = { 131, 131, 131, 131, 131, 131, 131, 131, 131, 131}; +const q15_t DMR_LEVELC[] = {-131, -131, -131, -131, -131, -131, -131, -131, -131, -131}; +const q15_t DMR_LEVELD[] = {-395, -395, -395, -395, -395, -395, -395, -395, -395, -395}; CDMRDMOTX::CDMRDMOTX() : @@ -52,7 +44,7 @@ m_poPtr(0U), m_txDelay(240U), // 200ms m_count(0U) { - ::memset(m_modState, 0x00U, 70U * sizeof(q15_t)); + ::memset(m_modState, 0x00U, 90U * sizeof(q15_t)); m_modFilter.numTaps = DMR_C4FSK_FILTER_LEN; m_modFilter.pState = m_modState; diff --git a/DMRDMOTX.h b/DMRDMOTX.h index 3650d0d..c93c703 100644 --- a/DMRDMOTX.h +++ b/DMRDMOTX.h @@ -40,7 +40,7 @@ public: private: CSerialRB m_fifo; arm_fir_instance_q15 m_modFilter; - q15_t m_modState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare + q15_t m_modState[90U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare uint8_t m_poBuffer[80U]; uint16_t m_poLen; uint16_t m_poPtr; diff --git a/DMRDefines.h b/DMRDefines.h index 3b2ccba..516ac2a 100644 --- a/DMRDefines.h +++ b/DMRDefines.h @@ -19,7 +19,7 @@ #if !defined(DMRDEFINES_H) #define DMRDEFINES_H -const unsigned int DMR_RADIO_SYMBOL_LENGTH = 5U; // At 24 kHz sample rate +const unsigned int DMR_RADIO_SYMBOL_LENGTH = 10U; // At 48 kHz sample rate const unsigned int DMR_FRAME_LENGTH_BYTES = 33U; const unsigned int DMR_FRAME_LENGTH_BITS = DMR_FRAME_LENGTH_BYTES * 8U; diff --git a/DMRSlotRX.cpp b/DMRSlotRX.cpp index 6abe38d..2b83353 100644 --- a/DMRSlotRX.cpp +++ b/DMRSlotRX.cpp @@ -24,8 +24,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) @@ -101,7 +101,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 7be5552..98acb4e 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/DMRTX.cpp b/DMRTX.cpp index 684f659..c10ac2a 100644 --- a/DMRTX.cpp +++ b/DMRTX.cpp @@ -23,23 +23,15 @@ #include "Globals.h" #include "DMRSlotType.h" -#if defined(WIDE_C4FSK_FILTERS_TX) -// Generated using rcosdesign(0.2, 4, 5, 'sqrt') in MATLAB -static q15_t DMR_C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, - 11310, 7041, 2684, -775, -2724, -3060, -2158, -680, 688, 0}; -const uint16_t DMR_C4FSK_FILTER_LEN = 22U; -#else -// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB -static q15_t DMR_C4FSK_FILTER[] = {401, 104, -340, -731, -847, -553, 112, 909, 1472, 1450, 683, -675, -2144, -3040, -2706, -770, 2667, 6995, - 11237, 14331, 15464, 14331, 11237, 6995, 2667, -770, -2706, -3040, -2144, -675, 683, 1450, 1472, 909, 112, - -553, -847, -731, -340, 104, 401, 0}; +// Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB +static q15_t DMR_C4FSK_FILTER[] = {486, 39, -480, -1022, -1526, -1928, -2164, -2178, -1927, -1384, -548, 561, 1898, 3399, 4980, 6546, 7999, 9246, 10202, 10803, 11008, 10803, 10202, 9246, + 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0}; const uint16_t DMR_C4FSK_FILTER_LEN = 42U; -#endif -const q15_t DMR_LEVELA[] = { 640, 640 , 640, 640, 640}; -const q15_t DMR_LEVELB[] = { 213, 213, 213, 213, 213}; -const q15_t DMR_LEVELC[] = {-213, -213, -213, -213, -213}; -const q15_t DMR_LEVELD[] = {-640, -640, -640, -640, -640}; +const q15_t DMR_LEVELA[] = { 395, 395, 395, 395, 395, 395, 395, 395, 395, 395}; +const q15_t DMR_LEVELB[] = { 131, 131, 131, 131, 131, 131, 131, 131, 131, 131}; +const q15_t DMR_LEVELC[] = {-131, -131, -131, -131, -131, -131, -131, -131, -131, -131}; +const q15_t DMR_LEVELD[] = {-395, -395, -395, -395, -395, -395, -395, -395, -395, -395}; // The PR FILL and Data Sync pattern. const uint8_t IDLE_DATA[] = @@ -77,7 +69,7 @@ m_poPtr(0U), m_count(0U), m_abort() { - ::memset(m_modState, 0x00U, 70U * sizeof(q15_t)); + ::memset(m_modState, 0x00U, 90U * sizeof(q15_t)); m_modFilter.numTaps = DMR_C4FSK_FILTER_LEN; m_modFilter.pState = m_modState; diff --git a/DMRTX.h b/DMRTX.h index 599b8fe..3e94e2c 100644 --- a/DMRTX.h +++ b/DMRTX.h @@ -57,7 +57,7 @@ public: private: CSerialRB m_fifo[2U]; arm_fir_instance_q15 m_modFilter; - q15_t m_modState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare + q15_t m_modState[90U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare DMRTXSTATE m_state; uint8_t m_idle[DMR_FRAME_LENGTH_BYTES]; uint8_t m_cachPtr; diff --git a/DStarDefines.h b/DStarDefines.h index 6255028..7a7d8ec 100644 --- a/DStarDefines.h +++ b/DStarDefines.h @@ -19,7 +19,7 @@ #if !defined(DSTARDEFINES_H) #define DSTARDEFINES_H -const unsigned int DSTAR_RADIO_BIT_LENGTH = 5U; // At 24 kHz sample rate +const unsigned int DSTAR_RADIO_BIT_LENGTH = 10U; // At 48 kHz sample rate const unsigned int DSTAR_HEADER_LENGTH_BYTES = 41U; const unsigned int DSTAR_HEADER_LENGTH_BITS = DSTAR_HEADER_LENGTH_BYTES * 8U; diff --git a/DStarTX.cpp b/DStarTX.cpp index 03caa31..08c466a 100644 --- a/DStarTX.cpp +++ b/DStarTX.cpp @@ -28,12 +28,12 @@ const uint8_t BIT_SYNC = 0xAAU; const uint8_t FRAME_SYNC[] = {0xEAU, 0xA6U, 0x00U}; -// Generated using gaussfir(0.5, 4, 5) in MATLAB -static q15_t DSTAR_GMSK_FILTER[] = {8, 104, 760, 3158, 7421, 9866, 7421, 3158, 760, 104, 8, 0}; -const uint16_t DSTAR_GMSK_FILTER_LEN = 12U; +// Generated using gaussfir(0.5, 4, 10) in MATLAB +static q15_t DSTAR_GMSK_FILTER[] = {1, 4, 15, 52, 151, 380, 832, 1579, 2599, 3710, 4594, 4933, 4594, 3710, 2599, 1579, 832, 380, 151, 52, 15, 4, 1, 0}; +const uint16_t DSTAR_GMSK_FILTER_LEN = 24U; -const q15_t DSTAR_LEVEL0[] = {-800, -800, -800, -800, -800}; -const q15_t DSTAR_LEVEL1[] = { 800, 800, 800, 800, 800}; +const q15_t DSTAR_LEVEL0[] = {-808, -808, -808, -808, -808, -808, -808, -808, -808, -808}; +const q15_t DSTAR_LEVEL1[] = { 808, 808, 808, 808, 808, 808, 808, 808, 808, 808}; const uint8_t BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U, 0x02U, 0x01U}; @@ -198,7 +198,7 @@ m_poPtr(0U), m_txDelay(60U), // 100ms m_count(0U) { - ::memset(m_modState, 0x00U, 60U * sizeof(q15_t)); + ::memset(m_modState, 0x00U, 80U * sizeof(q15_t)); m_modFilter.numTaps = DSTAR_GMSK_FILTER_LEN; m_modFilter.pState = m_modState; diff --git a/DStarTX.h b/DStarTX.h index 828974c..2dc3360 100644 --- a/DStarTX.h +++ b/DStarTX.h @@ -40,7 +40,7 @@ public: private: CSerialRB m_buffer; arm_fir_instance_q15 m_modFilter; - q15_t m_modState[60U]; // NoTaps + BlockSize - 1, 12 + 40 - 1 plus some spare + q15_t m_modState[80U]; // NoTaps + BlockSize - 1, 12 + 40 - 1 plus some spare uint8_t m_poBuffer[500U]; uint16_t m_poLen; uint16_t m_poPtr; diff --git a/IO.cpp b/IO.cpp index 006a47c..a861e46 100644 --- a/IO.cpp +++ b/IO.cpp @@ -24,22 +24,14 @@ #include "Globals.h" #include "IO.h" -#if defined(WIDE_C4FSK_FILTERS_RX) -// Generated using rcosdesign(0.2, 4, 5, 'sqrt') in MATLAB -static q15_t C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, - 11310, 7041, 2684, -775, -2724, -3060, -2158, -680, 688, 0}; -const uint16_t C4FSK_FILTER_LEN = 22U; -#else -// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB -static q15_t C4FSK_FILTER[] = {401, 104, -340, -731, -847, -553, 112, 909, 1472, 1450, 683, -675, -2144, -3040, -2706, -770, 2667, 6995, - 11237, 14331, 15464, 14331, 11237, 6995, 2667, -770, -2706, -3040, -2144, -675, 683, 1450, 1472, 909, 112, - -553, -847, -731, -340, 104, 401, 0}; +// Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB +static q15_t C4FSK_FILTER[] = {486, 39, -480, -1022, -1526, -1928, -2164, -2178, -1927, -1384, -548, 561, 1898, 3399, 4980, 6546, 7999, 9246, 10202, 10803, 11008, 10803, 10202, 9246, + 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0}; const uint16_t C4FSK_FILTER_LEN = 42U; -#endif -// Generated using gaussfir(0.5, 4, 5) in MATLAB -static q15_t GMSK_FILTER[] = {8, 104, 760, 3158, 7421, 9866, 7421, 3158, 760, 104, 8, 0}; -const uint16_t GMSK_FILTER_LEN = 12U; +// Generated using gaussfir(0.5, 4, 10) in MATLAB +static q15_t GMSK_FILTER[] = {1, 4, 15, 52, 151, 380, 832, 1579, 2599, 3710, 4594, 4933, 4594, 3710, 2599, 1579, 832, 380, 151, 52, 15, 4, 1, 0}; +const uint16_t GMSK_FILTER_LEN = 24U; const uint16_t DC_OFFSET = 2048U; @@ -100,7 +92,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); @@ -111,13 +103,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/IO.h b/IO.h index 357c04e..e8ecdce 100644 --- a/IO.h +++ b/IO.h @@ -63,7 +63,7 @@ private: arm_fir_instance_q15 m_C4FSKFilter; arm_fir_instance_q15 m_GMSKFilter; q15_t m_C4FSKState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare - q15_t m_GMSKState[40U]; // NoTaps + BlockSize - 1, 12 + 20 - 1 plus some spare + q15_t m_GMSKState[80U]; // NoTaps + BlockSize - 1, 12 + 20 - 1 plus some spare bool m_pttInvert; q15_t m_rxLevel; diff --git a/IODue.cpp b/IODue.cpp index 17d4fa4..0e44d8e 100644 --- a/IODue.cpp +++ b/IODue.cpp @@ -133,11 +133,11 @@ void CIO::startInt() TC_CMR_ACPA_CLEAR | TC_CMR_ACPC_CLEAR | TC_CMR_BCPB_CLEAR | TC_CMR_BCPC_CLEAR; #if defined(EXTERNAL_OSC) - t->TC_RC = EXTERNAL_OSC / 24000; // Counter resets on RC, so sets period in terms of the external clock - t->TC_RA = EXTERNAL_OSC / 48000; // Roughly square wave + t->TC_RC = EXTERNAL_OSC / 48000; // Counter resets on RC, so sets period in terms of the external clock + t->TC_RA = EXTERNAL_OSC / 96000; // Roughly square wave #else - t->TC_RC = 1750; // Counter resets on RC, so sets period in terms of 42MHz internal clock - t->TC_RA = 880; // Roughly square wave + t->TC_RC = 875; // Counter resets on RC, so sets period in terms of 42MHz internal clock + t->TC_RA = 438; // Roughly square wave #endif t->TC_CMR = (t->TC_CMR & 0xFFF0FFFF) | TC_CMR_ACPA_CLEAR | TC_CMR_ACPC_SET; // Set clear and set from RA and RC compares t->TC_CCR = TC_CCR_CLKEN | TC_CCR_SWTRG; // re-enable local clocking and switch to hardware trigger source. diff --git a/IOSTM.cpp b/IOSTM.cpp index bb27e20..b8fb772 100644 --- a/IOSTM.cpp +++ b/IOSTM.cpp @@ -207,7 +207,7 @@ EXT_CLK PA15 input const uint16_t DC_OFFSET = 2048U; // Sampling frequency -#define SAMP_FREQ 24000 +#define SAMP_FREQ 48000 extern "C" { void TIM2_IRQHandler() { diff --git a/IOTeensy.cpp b/IOTeensy.cpp index 18d9d4d..62819fe 100644 --- a/IOTeensy.cpp +++ b/IOTeensy.cpp @@ -121,7 +121,7 @@ void CIO::startInt() #endif #if defined(EXTERNAL_OSC) - // Set ADC0 to trigger from the LPTMR at 24 kHz + // Set ADC0 to trigger from the LPTMR at 48 kHz SIM_SOPT7 = SIM_SOPT7_ADC0ALTTRGEN | // Enable ADC0 alternate trigger SIM_SOPT7_ADC0PRETRGSEL | // Enable ADC0 pre-trigger SIM_SOPT7_ADC0TRGSEL(14); // Trigger ADC0 by LPTMR0 @@ -131,14 +131,14 @@ void CIO::startInt() SIM_SCGC5 |= SIM_SCGC5_LPTIMER; // Enable Low Power Timer Access LPTMR0_CSR = 0; // Disable LPTMR0_PSR = LPTMR_PSR_PBYP; // Bypass prescaler/filter - LPTMR0_CMR = (EXTERNAL_OSC / 24000) - 1; // Frequency divided by CMR + 1 + LPTMR0_CMR = (EXTERNAL_OSC / 48000) - 1; // Frequency divided by CMR + 1 LPTMR0_CSR = LPTMR_CSR_TPS(2) | // Pin: 0=CMP0, 1=xtal, 2=pin13 LPTMR_CSR_TMS; // Mode Select, 0=timer, 1=counter LPTMR0_CSR |= LPTMR_CSR_TEN; // Enable #else - // Setup PDB for ADC0 at 24 kHz + // Setup PDB for ADC0 at 48 kHz SIM_SCGC6 |= SIM_SCGC6_PDB; // Enable PDB clock - PDB0_MOD = (F_BUS / 24000) - 1; // Timer period - 1 + PDB0_MOD = (F_BUS / 48000) - 1; // Timer period - 1 PDB0_IDLY = 0; // Interrupt delay PDB0_CH0C1 = PDB_CHnC1_TOS | PDB_CHnC1_EN; // Enable pre-trigger for ADC0 PDB0_SC = PDB_SC_TRGSEL(15) | PDB_SC_PDBEN | // SW trigger, enable interrupts, continuous mode diff --git a/P25Defines.h b/P25Defines.h index da21229..897dfb8 100644 --- a/P25Defines.h +++ b/P25Defines.h @@ -19,7 +19,7 @@ #if !defined(P25DEFINES_H) #define P25DEFINES_H -const unsigned int P25_RADIO_SYMBOL_LENGTH = 5U; // At 24 kHz sample rate +const unsigned int P25_RADIO_SYMBOL_LENGTH = 10U; // At 48 kHz sample rate const unsigned int P25_HDR_FRAME_LENGTH_BYTES = 99U; const unsigned int P25_HDR_FRAME_LENGTH_BITS = P25_HDR_FRAME_LENGTH_BYTES * 8U; diff --git a/P25TX.cpp b/P25TX.cpp index 909fb56..70567e5 100644 --- a/P25TX.cpp +++ b/P25TX.cpp @@ -24,18 +24,10 @@ #include "P25Defines.h" -#if defined(WIDE_C4FSK_FILTERS_TX) -// Generated using rcosdesign(0.2, 4, 5, 'sqrt') in MATLAB -static q15_t P25_C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, - 11310, 7041, 2684, -775, -2724, -3060, -2158, -680, 688, 0}; -const uint16_t P25_C4FSK_FILTER_LEN = 22U; -#else -// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB -static q15_t P25_C4FSK_FILTER[] = {401, 104, -340, -731, -847, -553, 112, 909, 1472, 1450, 683, -675, -2144, -3040, -2706, -770, 2667, 6995, - 11237, 14331, 15464, 14331, 11237, 6995, 2667, -770, -2706, -3040, -2144, -675, 683, 1450, 1472, 909, 112, - -553, -847, -731, -340, 104, 401, 0}; +// Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB +static q15_t P25_C4FSK_FILTER[] = {486, 39, -480, -1022, -1526, -1928, -2164, -2178, -1927, -1384, -548, 561, 1898, 3399, 4980, 6546, 7999, 9246, 10202, 10803, 11008, 10803, 10202, 9246, + 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0}; const uint16_t P25_C4FSK_FILTER_LEN = 42U; -#endif // Generated in MATLAB using the following commands, and then normalised for unity gain // shape2 = 'Inverse-sinc Lowpass'; @@ -46,10 +38,10 @@ static q15_t P25_LP_FILTER[] = {170, 401, 340, -203, -715, -478, 281, 419, -440, 281, -478, -715, -203, 340, 401, 170}; const uint16_t P25_LP_FILTER_LEN = 44U; -const q15_t P25_LEVELA[] = { 495, 495, 495, 495, 495}; -const q15_t P25_LEVELB[] = { 165, 165, 165, 165, 165}; -const q15_t P25_LEVELC[] = {-165, -165, -165, -165, -165}; -const q15_t P25_LEVELD[] = {-495, -495, -495, -495, -495}; +const q15_t P25_LEVELA[] = { 305, 305, 305, 305, 305, 305, 305, 305, 305, 305}; +const q15_t P25_LEVELB[] = { 102, 102, 102, 102, 102, 102, 102, 102, 102, 102}; +const q15_t P25_LEVELC[] = {-102, -102, -102, -102, -102, -102, -102, -102, -102, -102}; +const q15_t P25_LEVELD[] = {-305, -305, -305, -305, -305, -305, -305, -305, -305, -305}; const uint8_t P25_START_SYNC = 0x77U; @@ -65,8 +57,8 @@ m_poPtr(0U), m_txDelay(240U), // 200ms m_count(0U) { - ::memset(m_modState, 0x00U, 70U * sizeof(q15_t)); - ::memset(m_lpState, 0x00U, 70U * sizeof(q15_t)); + ::memset(m_modState, 0x00U, 90U * sizeof(q15_t)); + ::memset(m_lpState, 0x00U, 90U * sizeof(q15_t)); m_modFilter.numTaps = P25_C4FSK_FILTER_LEN; m_modFilter.pState = m_modState; diff --git a/P25TX.h b/P25TX.h index bbe6393..ef93f2e 100644 --- a/P25TX.h +++ b/P25TX.h @@ -39,8 +39,8 @@ private: CSerialRB m_buffer; arm_fir_instance_q15 m_modFilter; arm_fir_instance_q15 m_lpFilter; - q15_t m_modState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare - q15_t m_lpState[70U]; // NoTaps + BlockSize - 1, 44 + 20 - 1 plus some spare + q15_t m_modState[90U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare + q15_t m_lpState[90U]; // NoTaps + BlockSize - 1, 44 + 20 - 1 plus some spare uint8_t m_poBuffer[920U]; uint16_t m_poLen; uint16_t m_poPtr; diff --git a/SerialPort.cpp b/SerialPort.cpp index 29535f7..41588c1 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -68,9 +68,9 @@ const uint8_t MMDVM_DEBUG4 = 0xF4U; const uint8_t MMDVM_DEBUG5 = 0xF5U; #if defined(EXTERNAL_OSC) -const uint8_t HARDWARE[] = "MMDVM 20161124 TCXO (D-Star/DMR/System Fusion/P25/CW Id)"; +const uint8_t HARDWARE[] = "MMDVM 20161124 TCXO 48kHz (D-Star/DMR/System Fusion/P25/CW Id)"; #else -const uint8_t HARDWARE[] = "MMDVM 20161124 (D-Star/DMR/System Fusion/P25/CW Id)"; +const uint8_t HARDWARE[] = "MMDVM 20161124 48kHz (D-Star/DMR/System Fusion/P25/CW Id)"; #endif const uint8_t PROTOCOL_VERSION = 1U; diff --git a/YSFDefines.h b/YSFDefines.h index afbd60e..9e65f4a 100644 --- a/YSFDefines.h +++ b/YSFDefines.h @@ -19,7 +19,7 @@ #if !defined(YSFDEFINES_H) #define YSFDEFINES_H -const unsigned int YSF_RADIO_SYMBOL_LENGTH = 5U; // At 24 kHz sample rate +const unsigned int YSF_RADIO_SYMBOL_LENGTH = 10U; // At 48 kHz sample rate const unsigned int YSF_FRAME_LENGTH_BYTES = 120U; const unsigned int YSF_FRAME_LENGTH_BITS = YSF_FRAME_LENGTH_BYTES * 8U; diff --git a/YSFTX.cpp b/YSFTX.cpp index d3e20a3..ee9c1e8 100644 --- a/YSFTX.cpp +++ b/YSFTX.cpp @@ -24,23 +24,15 @@ #include "YSFDefines.h" -#if defined(WIDE_C4FSK_FILTERS_TX) -// Generated using rcosdesign(0.2, 4, 5, 'sqrt') in MATLAB -static q15_t YSF_C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, - 11310, 7041, 2684, -775, -2724, -3060, -2158, -680, 688, 0}; -const uint16_t YSF_C4FSK_FILTER_LEN = 22U; -#else -// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB -static q15_t YSF_C4FSK_FILTER[] = {401, 104, -340, -731, -847, -553, 112, 909, 1472, 1450, 683, -675, -2144, -3040, -2706, -770, 2667, 6995, - 11237, 14331, 15464, 14331, 11237, 6995, 2667, -770, -2706, -3040, -2144, -675, 683, 1450, 1472, 909, 112, - -553, -847, -731, -340, 104, 401, 0}; +// Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB +static q15_t YSF_C4FSK_FILTER[] = {486, 39, -480, -1022, -1526, -1928, -2164, -2178, -1927, -1384, -548, 561, 1898, 3399, 4980, 6546, 7999, 9246, 10202, 10803, 11008, 10803, 10202, 9246, + 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0}; const uint16_t YSF_C4FSK_FILTER_LEN = 42U; -#endif -const q15_t YSF_LEVELA[] = { 809, 809, 809, 809, 809}; -const q15_t YSF_LEVELB[] = { 269, 269, 269, 269, 269}; -const q15_t YSF_LEVELC[] = {-269, -269, -269, -269, -269}; -const q15_t YSF_LEVELD[] = {-809, -809, -809, -809, -809}; +const q15_t YSF_LEVELA[] = { 499, 499, 499, 499, 499, 499, 499, 499, 499, 499}; +const q15_t YSF_LEVELB[] = { 166, 166, 166, 166, 166, 166, 166, 166, 166, 166}; +const q15_t YSF_LEVELC[] = {-166, -166, -166, -166, -166, -166, -166, -166, -166, -166}; +const q15_t YSF_LEVELD[] = {-499, -499, -499, -499, -499, -499, -499, -499, -499, -499}; const uint8_t YSF_START_SYNC = 0x77U; const uint8_t YSF_END_SYNC = 0xFFU; @@ -55,7 +47,7 @@ m_poPtr(0U), m_txDelay(240U), // 200ms m_count(0U) { - ::memset(m_modState, 0x00U, 70U * sizeof(q15_t)); + ::memset(m_modState, 0x00U, 90U * sizeof(q15_t)); m_modFilter.numTaps = YSF_C4FSK_FILTER_LEN; m_modFilter.pState = m_modState; diff --git a/YSFTX.h b/YSFTX.h index 309cacc..d961e02 100644 --- a/YSFTX.h +++ b/YSFTX.h @@ -38,7 +38,7 @@ public: private: CSerialRB m_buffer; arm_fir_instance_q15 m_modFilter; - q15_t m_modState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare + q15_t m_modState[90U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare uint8_t m_poBuffer[920U]; uint16_t m_poLen; uint16_t m_poPtr;