Update to 48 kHz sample rate.

48kHz
Jonathan Naylor 2016-12-19 15:27:52 +00:00
parent 2fad06093f
commit 37080d9901
24 changed files with 79 additions and 118 deletions

View File

@ -24,12 +24,13 @@
#include "CWIdTX.h" #include "CWIdTX.h"
q15_t TONE[] = { 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[] = { 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; const uint8_t DOT_LENGTH = 50U;

View File

@ -22,7 +22,7 @@
#include "Config.h" #include "Config.h"
#include "DMRDefines.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 { enum DMORX_STATE {
DMORXS_NONE, DMORXS_NONE,

View File

@ -23,23 +23,15 @@
#include "Globals.h" #include "Globals.h"
#include "DMRSlotType.h" #include "DMRSlotType.h"
#if defined(WIDE_C4FSK_FILTERS_TX) // Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB
// Generated using rcosdesign(0.2, 4, 5, '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,
static q15_t DMR_C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0};
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};
const uint16_t DMR_C4FSK_FILTER_LEN = 42U; const uint16_t DMR_C4FSK_FILTER_LEN = 42U;
#endif
const q15_t DMR_LEVELA[] = { 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[] = { 213, 213, 213, 213, 213}; const q15_t DMR_LEVELB[] = { 131, 131, 131, 131, 131, 131, 131, 131, 131, 131};
const q15_t DMR_LEVELC[] = {-213, -213, -213, -213, -213}; const q15_t DMR_LEVELC[] = {-131, -131, -131, -131, -131, -131, -131, -131, -131, -131};
const q15_t DMR_LEVELD[] = {-640, -640, -640, -640, -640}; const q15_t DMR_LEVELD[] = {-395, -395, -395, -395, -395, -395, -395, -395, -395, -395};
CDMRDMOTX::CDMRDMOTX() : CDMRDMOTX::CDMRDMOTX() :
@ -52,7 +44,7 @@ m_poPtr(0U),
m_txDelay(240U), // 200ms m_txDelay(240U), // 200ms
m_count(0U) 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.numTaps = DMR_C4FSK_FILTER_LEN;
m_modFilter.pState = m_modState; m_modFilter.pState = m_modState;

View File

@ -40,7 +40,7 @@ public:
private: private:
CSerialRB m_fifo; CSerialRB m_fifo;
arm_fir_instance_q15 m_modFilter; 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]; uint8_t m_poBuffer[80U];
uint16_t m_poLen; uint16_t m_poLen;
uint16_t m_poPtr; uint16_t m_poPtr;

View File

@ -19,7 +19,7 @@
#if !defined(DMRDEFINES_H) #if !defined(DMRDEFINES_H)
#define 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_BYTES = 33U;
const unsigned int DMR_FRAME_LENGTH_BITS = DMR_FRAME_LENGTH_BYTES * 8U; const unsigned int DMR_FRAME_LENGTH_BITS = DMR_FRAME_LENGTH_BYTES * 8U;

View File

@ -24,8 +24,8 @@
#include "DMRSlotType.h" #include "DMRSlotType.h"
#include "Utils.h" #include "Utils.h"
const uint16_t SCAN_START = 400U; const uint16_t SCAN_START = 790U;
const uint16_t SCAN_END = 490U; const uint16_t SCAN_END = 920U;
const q15_t SCALING_FACTOR = 19505; // Q15(0.60) 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; return m_state != DMRRXS_NONE;
// Ensure that the buffer doesn't overflow // 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; return m_state != DMRRXS_NONE;
m_buffer[m_dataPtr] = sample; m_buffer[m_dataPtr] = sample;

View File

@ -44,7 +44,7 @@ public:
private: private:
bool m_slot; bool m_slot;
uint32_t m_bitBuffer[DMR_RADIO_SYMBOL_LENGTH]; 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_bitPtr;
uint16_t m_dataPtr; uint16_t m_dataPtr;
uint16_t m_syncPtr; uint16_t m_syncPtr;

View File

@ -23,23 +23,15 @@
#include "Globals.h" #include "Globals.h"
#include "DMRSlotType.h" #include "DMRSlotType.h"
#if defined(WIDE_C4FSK_FILTERS_TX) // Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB
// Generated using rcosdesign(0.2, 4, 5, '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,
static q15_t DMR_C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0};
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};
const uint16_t DMR_C4FSK_FILTER_LEN = 42U; const uint16_t DMR_C4FSK_FILTER_LEN = 42U;
#endif
const q15_t DMR_LEVELA[] = { 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[] = { 213, 213, 213, 213, 213}; const q15_t DMR_LEVELB[] = { 131, 131, 131, 131, 131, 131, 131, 131, 131, 131};
const q15_t DMR_LEVELC[] = {-213, -213, -213, -213, -213}; const q15_t DMR_LEVELC[] = {-131, -131, -131, -131, -131, -131, -131, -131, -131, -131};
const q15_t DMR_LEVELD[] = {-640, -640, -640, -640, -640}; const q15_t DMR_LEVELD[] = {-395, -395, -395, -395, -395, -395, -395, -395, -395, -395};
// The PR FILL and Data Sync pattern. // The PR FILL and Data Sync pattern.
const uint8_t IDLE_DATA[] = const uint8_t IDLE_DATA[] =
@ -77,7 +69,7 @@ m_poPtr(0U),
m_count(0U), m_count(0U),
m_abort() 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.numTaps = DMR_C4FSK_FILTER_LEN;
m_modFilter.pState = m_modState; m_modFilter.pState = m_modState;

View File

@ -57,7 +57,7 @@ public:
private: private:
CSerialRB m_fifo[2U]; CSerialRB m_fifo[2U];
arm_fir_instance_q15 m_modFilter; 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; DMRTXSTATE m_state;
uint8_t m_idle[DMR_FRAME_LENGTH_BYTES]; uint8_t m_idle[DMR_FRAME_LENGTH_BYTES];
uint8_t m_cachPtr; uint8_t m_cachPtr;

View File

@ -19,7 +19,7 @@
#if !defined(DSTARDEFINES_H) #if !defined(DSTARDEFINES_H)
#define 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_BYTES = 41U;
const unsigned int DSTAR_HEADER_LENGTH_BITS = DSTAR_HEADER_LENGTH_BYTES * 8U; const unsigned int DSTAR_HEADER_LENGTH_BITS = DSTAR_HEADER_LENGTH_BYTES * 8U;

View File

@ -28,12 +28,12 @@ const uint8_t BIT_SYNC = 0xAAU;
const uint8_t FRAME_SYNC[] = {0xEAU, 0xA6U, 0x00U}; const uint8_t FRAME_SYNC[] = {0xEAU, 0xA6U, 0x00U};
// Generated using gaussfir(0.5, 4, 5) in MATLAB // Generated using gaussfir(0.5, 4, 10) in MATLAB
static q15_t DSTAR_GMSK_FILTER[] = {8, 104, 760, 3158, 7421, 9866, 7421, 3158, 760, 104, 8, 0}; 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 = 12U; const uint16_t DSTAR_GMSK_FILTER_LEN = 24U;
const q15_t DSTAR_LEVEL0[] = {-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[] = { 800, 800, 800, 800, 800}; 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}; 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_txDelay(60U), // 100ms
m_count(0U) 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.numTaps = DSTAR_GMSK_FILTER_LEN;
m_modFilter.pState = m_modState; m_modFilter.pState = m_modState;

View File

@ -40,7 +40,7 @@ public:
private: private:
CSerialRB m_buffer; CSerialRB m_buffer;
arm_fir_instance_q15 m_modFilter; 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]; uint8_t m_poBuffer[500U];
uint16_t m_poLen; uint16_t m_poLen;
uint16_t m_poPtr; uint16_t m_poPtr;

26
IO.cpp
View File

@ -24,22 +24,14 @@
#include "Globals.h" #include "Globals.h"
#include "IO.h" #include "IO.h"
#if defined(WIDE_C4FSK_FILTERS_RX) // Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB
// Generated using rcosdesign(0.2, 4, 5, '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,
static q15_t C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0};
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};
const uint16_t C4FSK_FILTER_LEN = 42U; const uint16_t C4FSK_FILTER_LEN = 42U;
#endif
// Generated using gaussfir(0.5, 4, 5) in MATLAB // Generated using gaussfir(0.5, 4, 10) in MATLAB
static q15_t GMSK_FILTER[] = {8, 104, 760, 3158, 7421, 9866, 7421, 3158, 760, 104, 8, 0}; 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 = 12U; const uint16_t GMSK_FILTER_LEN = 24U;
const uint16_t DC_OFFSET = 2048U; const uint16_t DC_OFFSET = 2048U;
@ -100,7 +92,7 @@ void CIO::process()
m_ledCount++; m_ledCount++;
if (m_started) { if (m_started) {
// Two seconds timeout // 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_DSTAR || m_modemState == STATE_DMR || m_modemState == STATE_YSF) {
if (m_modemState == STATE_DMR && m_tx) if (m_modemState == STATE_DMR && m_tx)
dmrTX.setStart(false); dmrTX.setStart(false);
@ -111,13 +103,13 @@ void CIO::process()
m_watchdog = 0U; m_watchdog = 0U;
} }
if (m_ledCount >= 24000U) { if (m_ledCount >= 48000U) {
m_ledCount = 0U; m_ledCount = 0U;
m_ledValue = !m_ledValue; m_ledValue = !m_ledValue;
setLEDInt(m_ledValue); setLEDInt(m_ledValue);
} }
} else { } else {
if (m_ledCount >= 240000U) { if (m_ledCount >= 480000U) {
m_ledCount = 0U; m_ledCount = 0U;
m_ledValue = !m_ledValue; m_ledValue = !m_ledValue;
setLEDInt(m_ledValue); setLEDInt(m_ledValue);

2
IO.h
View File

@ -63,7 +63,7 @@ private:
arm_fir_instance_q15 m_C4FSKFilter; arm_fir_instance_q15 m_C4FSKFilter;
arm_fir_instance_q15 m_GMSKFilter; arm_fir_instance_q15 m_GMSKFilter;
q15_t m_C4FSKState[70U]; // NoTaps + BlockSize - 1, 42 + 20 - 1 plus some spare 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; bool m_pttInvert;
q15_t m_rxLevel; q15_t m_rxLevel;

View File

@ -133,11 +133,11 @@ void CIO::startInt()
TC_CMR_ACPA_CLEAR | TC_CMR_ACPC_CLEAR | TC_CMR_ACPA_CLEAR | TC_CMR_ACPC_CLEAR |
TC_CMR_BCPB_CLEAR | TC_CMR_BCPC_CLEAR; TC_CMR_BCPB_CLEAR | TC_CMR_BCPC_CLEAR;
#if defined(EXTERNAL_OSC) #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_RC = EXTERNAL_OSC / 48000; // Counter resets on RC, so sets period in terms of the external clock
t->TC_RA = EXTERNAL_OSC / 48000; // Roughly square wave t->TC_RA = EXTERNAL_OSC / 96000; // Roughly square wave
#else #else
t->TC_RC = 1750; // Counter resets on RC, so sets period in terms of 42MHz internal clock t->TC_RC = 875; // Counter resets on RC, so sets period in terms of 42MHz internal clock
t->TC_RA = 880; // Roughly square wave t->TC_RA = 438; // Roughly square wave
#endif #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_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. t->TC_CCR = TC_CCR_CLKEN | TC_CCR_SWTRG; // re-enable local clocking and switch to hardware trigger source.

View File

@ -207,7 +207,7 @@ EXT_CLK PA15 input
const uint16_t DC_OFFSET = 2048U; const uint16_t DC_OFFSET = 2048U;
// Sampling frequency // Sampling frequency
#define SAMP_FREQ 24000 #define SAMP_FREQ 48000
extern "C" { extern "C" {
void TIM2_IRQHandler() { void TIM2_IRQHandler() {

View File

@ -121,7 +121,7 @@ void CIO::startInt()
#endif #endif
#if defined(EXTERNAL_OSC) #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 = SIM_SOPT7_ADC0ALTTRGEN | // Enable ADC0 alternate trigger
SIM_SOPT7_ADC0PRETRGSEL | // Enable ADC0 pre-trigger SIM_SOPT7_ADC0PRETRGSEL | // Enable ADC0 pre-trigger
SIM_SOPT7_ADC0TRGSEL(14); // Trigger ADC0 by LPTMR0 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 SIM_SCGC5 |= SIM_SCGC5_LPTIMER; // Enable Low Power Timer Access
LPTMR0_CSR = 0; // Disable LPTMR0_CSR = 0; // Disable
LPTMR0_PSR = LPTMR_PSR_PBYP; // Bypass prescaler/filter 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 LPTMR0_CSR = LPTMR_CSR_TPS(2) | // Pin: 0=CMP0, 1=xtal, 2=pin13
LPTMR_CSR_TMS; // Mode Select, 0=timer, 1=counter LPTMR_CSR_TMS; // Mode Select, 0=timer, 1=counter
LPTMR0_CSR |= LPTMR_CSR_TEN; // Enable LPTMR0_CSR |= LPTMR_CSR_TEN; // Enable
#else #else
// Setup PDB for ADC0 at 24 kHz // Setup PDB for ADC0 at 48 kHz
SIM_SCGC6 |= SIM_SCGC6_PDB; // Enable PDB clock 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_IDLY = 0; // Interrupt delay
PDB0_CH0C1 = PDB_CHnC1_TOS | PDB_CHnC1_EN; // Enable pre-trigger for ADC0 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 PDB0_SC = PDB_SC_TRGSEL(15) | PDB_SC_PDBEN | // SW trigger, enable interrupts, continuous mode

View File

@ -19,7 +19,7 @@
#if !defined(P25DEFINES_H) #if !defined(P25DEFINES_H)
#define 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_BYTES = 99U;
const unsigned int P25_HDR_FRAME_LENGTH_BITS = P25_HDR_FRAME_LENGTH_BYTES * 8U; const unsigned int P25_HDR_FRAME_LENGTH_BITS = P25_HDR_FRAME_LENGTH_BYTES * 8U;

View File

@ -24,18 +24,10 @@
#include "P25Defines.h" #include "P25Defines.h"
#if defined(WIDE_C4FSK_FILTERS_TX) // Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB
// Generated using rcosdesign(0.2, 4, 5, '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,
static q15_t P25_C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0};
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};
const uint16_t P25_C4FSK_FILTER_LEN = 42U; const uint16_t P25_C4FSK_FILTER_LEN = 42U;
#endif
// Generated in MATLAB using the following commands, and then normalised for unity gain // Generated in MATLAB using the following commands, and then normalised for unity gain
// shape2 = 'Inverse-sinc Lowpass'; // 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}; 281, -478, -715, -203, 340, 401, 170};
const uint16_t P25_LP_FILTER_LEN = 44U; const uint16_t P25_LP_FILTER_LEN = 44U;
const q15_t P25_LEVELA[] = { 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[] = { 165, 165, 165, 165, 165}; const q15_t P25_LEVELB[] = { 102, 102, 102, 102, 102, 102, 102, 102, 102, 102};
const q15_t P25_LEVELC[] = {-165, -165, -165, -165, -165}; const q15_t P25_LEVELC[] = {-102, -102, -102, -102, -102, -102, -102, -102, -102, -102};
const q15_t P25_LEVELD[] = {-495, -495, -495, -495, -495}; const q15_t P25_LEVELD[] = {-305, -305, -305, -305, -305, -305, -305, -305, -305, -305};
const uint8_t P25_START_SYNC = 0x77U; const uint8_t P25_START_SYNC = 0x77U;
@ -65,8 +57,8 @@ m_poPtr(0U),
m_txDelay(240U), // 200ms m_txDelay(240U), // 200ms
m_count(0U) m_count(0U)
{ {
::memset(m_modState, 0x00U, 70U * sizeof(q15_t)); ::memset(m_modState, 0x00U, 90U * sizeof(q15_t));
::memset(m_lpState, 0x00U, 70U * sizeof(q15_t)); ::memset(m_lpState, 0x00U, 90U * sizeof(q15_t));
m_modFilter.numTaps = P25_C4FSK_FILTER_LEN; m_modFilter.numTaps = P25_C4FSK_FILTER_LEN;
m_modFilter.pState = m_modState; m_modFilter.pState = m_modState;

View File

@ -39,8 +39,8 @@ private:
CSerialRB m_buffer; CSerialRB m_buffer;
arm_fir_instance_q15 m_modFilter; arm_fir_instance_q15 m_modFilter;
arm_fir_instance_q15 m_lpFilter; arm_fir_instance_q15 m_lpFilter;
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
q15_t m_lpState[70U]; // NoTaps + BlockSize - 1, 44 + 20 - 1 plus some spare q15_t m_lpState[90U]; // NoTaps + BlockSize - 1, 44 + 20 - 1 plus some spare
uint8_t m_poBuffer[920U]; uint8_t m_poBuffer[920U];
uint16_t m_poLen; uint16_t m_poLen;
uint16_t m_poPtr; uint16_t m_poPtr;

View File

@ -68,9 +68,9 @@ const uint8_t MMDVM_DEBUG4 = 0xF4U;
const uint8_t MMDVM_DEBUG5 = 0xF5U; const uint8_t MMDVM_DEBUG5 = 0xF5U;
#if defined(EXTERNAL_OSC) #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 #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 #endif
const uint8_t PROTOCOL_VERSION = 1U; const uint8_t PROTOCOL_VERSION = 1U;

View File

@ -19,7 +19,7 @@
#if !defined(YSFDEFINES_H) #if !defined(YSFDEFINES_H)
#define 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_BYTES = 120U;
const unsigned int YSF_FRAME_LENGTH_BITS = YSF_FRAME_LENGTH_BYTES * 8U; const unsigned int YSF_FRAME_LENGTH_BITS = YSF_FRAME_LENGTH_BYTES * 8U;

View File

@ -24,23 +24,15 @@
#include "YSFDefines.h" #include "YSFDefines.h"
#if defined(WIDE_C4FSK_FILTERS_TX) // Generated using rcosdesign(0.2, 4, 10, 'sqrt') in MATLAB
// Generated using rcosdesign(0.2, 4, 5, '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,
static q15_t YSF_C4FSK_FILTER[] = {688, -680, -2158, -3060, -2724, -775, 2684, 7041, 11310, 14425, 15565, 14425, 7999, 6546, 4980, 3399, 1898, 561, -548, -1384, -1927, -2178, -2164, -1928, -1526, -1022, -480, 39, 486, 0};
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};
const uint16_t YSF_C4FSK_FILTER_LEN = 42U; const uint16_t YSF_C4FSK_FILTER_LEN = 42U;
#endif
const q15_t YSF_LEVELA[] = { 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[] = { 269, 269, 269, 269, 269}; const q15_t YSF_LEVELB[] = { 166, 166, 166, 166, 166, 166, 166, 166, 166, 166};
const q15_t YSF_LEVELC[] = {-269, -269, -269, -269, -269}; const q15_t YSF_LEVELC[] = {-166, -166, -166, -166, -166, -166, -166, -166, -166, -166};
const q15_t YSF_LEVELD[] = {-809, -809, -809, -809, -809}; 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_START_SYNC = 0x77U;
const uint8_t YSF_END_SYNC = 0xFFU; const uint8_t YSF_END_SYNC = 0xFFU;
@ -55,7 +47,7 @@ m_poPtr(0U),
m_txDelay(240U), // 200ms m_txDelay(240U), // 200ms
m_count(0U) 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.numTaps = YSF_C4FSK_FILTER_LEN;
m_modFilter.pState = m_modState; m_modFilter.pState = m_modState;

View File

@ -38,7 +38,7 @@ public:
private: private:
CSerialRB m_buffer; CSerialRB m_buffer;
arm_fir_instance_q15 m_modFilter; 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]; uint8_t m_poBuffer[920U];
uint16_t m_poLen; uint16_t m_poLen;
uint16_t m_poPtr; uint16_t m_poPtr;