📄 ofdm_defines.h
字号:
/*========================================================================
Filename: ofdm_defines.h
Description: This file contains the #define constants used in the OFDM power line modem.
It is generated by saving the excel spreadsheet ofdm_defines.xls as an unformated text file.
In the spreadsheet, bold values are direct entries, non-bold values are calculated.
Copyright (C) 2002 - 2003 Texas Instruments Incorporated
Texas Instruments Proprietary Information
Use subject to terms and conditions of TI Software License Agreement
Revision History:
==========================================================================*/
#ifndef OFDM_DEFINES_H // Header file guard
#define OFDM_DEFINES_H
#define VERSION 20030513 // id the parameters
//---- Word size ---------------------------------
#define BYTE_LEN 8
#define WORD_LEN 16
#define BYTE_MSB 0x0080U
#define WORD_MSB 0x8000U
//---- Modem characteristics ---------------------------------
// cyclic prefix time 0.25msec
#define FFT_LEN 256 // length of IFFT/FFT OFDM field
#define CYCLIC_PREFIX_LEN 42 // # of samples in cyclic prefix 64
#define WINDOW_LEN 16 // # of windowed samples in cyclic prefix
#define SYNC_FIELD_LEN 384 // # samples in sync field
#define NUM_PRE_FRAMES 8 // # pf frames in preamble
#define NUM_USER_BYTES 128 // # of user bytes in packet
#define WAVE_ZERO_PAD_FRONT 800 // # of zeros to pad simulated transmit waveform (Matab only)
#define WAVE_ZERO_PAD_BACK 500 // # of zeros to pad simulated transmit waveform (Matab only)
//---- get carrier frequency bins -----------------------------
// DSP sample rate (Fs) 250k 250
// lowest allowable carrier freq 48k 48 9
// highest allowable carrier freq 88k 88 94
// frequency resolution 1.0k
// carrrier range as % of Fs 19.14% 34.38%
#define CARRIER_LOW 51 // ((CARRIER_FREQ_LOW * FFT_LEN) + SAMPLE_FREQ-1) / SAMPLE_FREQ
#define CARRIER_HIGH 90 // (CARRIER_FREQ_HIGH * FFT_LEN) / SAMPLE_FREQ
#define CARRIER_LEN 40 // CARRIER_HIGH - CARRIER_LOW + 1
//---- calc the number of bits to send in the packet ----------------------------
// total un-encoded bytes 131 userBytes + crcBytes + viterbiPadByte
// total bits 1048 8 bit bytes
// num encoded bits 2096 total bits / rate
// num bits / frame 80 bits
// AFE_SIZE 3 words
// RX_SRC_INC 2 words
#define NUM_DATA_BLOCKS 27 // CEILING(num_encoded_bits/num_bits_per_frame)
#define NUM_SYMBOLS 1080 // total number of symbols in message
#define DATA_FRAMES_PER_BLOCK 3 // # of time to repeat each frame
#define SYMBOL_OFFSET 15 // shift each symbol this much from frame to frame in a block
#define DATA_BUFFER_LEN 68 // words = NUM_SYMBOLS*BITS_PER_SYMBOL*encoder_rate/WORD_LEN
// preamble+sync length 2560 NUM_PRE_FRAMES*FFT_LEN + SYNC_FIELD_LEN
// data field length 24154 NUM_DATA_FRAMES*(CYCLIC_PREFIX_LEN + FFT_LEN) + WINDOW_LEN
// receive waveform in Matlab: 28014
// number of receive buffer frames 8
#if COMPILE_MODE == MEX_COMPILE
#define TX_BUFFER_LEN 26714L // samples = preamble + data
#define RX_CIRC_BUFFER_LEN 32768L // size of receiver circular buffer
#else // DSP_COMPILE
#define TX_BUFFER_LEN 894L // samples = preamble + data
#ifdef _C5410
#define RX_CIRC_BUFFER_LEN 16256L // Maximum space available for receive circular buffer
#else
#define RX_CIRC_BUFFER_LEN 7680L // Size of receive circuluar buffer (max room in 5409
#endif
#endif
//---- CRC and scrambler ------------------------------------------
#define SCRAMBLER_LEN 127 // order 7 polynomial
#define CRC_LEN 16 // length in bits of CRC word
#define CRC_POLYNOMIAL 0x8005 // generator polynomial
#define CRC_TOPBIT 0x8000 // MSB
#define CRC_REG_INIT 0xFFFF // initial value for control register
#define CRC_BLOCK_LEN 16 // num bytes over which to calc a CRC word
//---- Convolutional encode/decode parameters -------------------------------
// encoder_rate 0.5
#define VITERBI_K 7 // length of encoder
#define VITERBI_NUM_STATES 64 // number of states in trellis
#define VITERBI_MEM_LEN 32 // length of shift reg in bits
#define VITERBI_MSB 0x80000000U // mask for MSB of 32bit word
#define VITERBI_LSB 0x00000001U // mask for LSB of 32bit word
#define VITERBI_CAR1_RE 200 // inital value for previous carrier1 for frame0
#define VITERBI_CAR1_IM 0
#define VITERBI_ENCODE_SHIFT 9 // shift data bit from MSB to bit 7 of state
#define VITERBI_DISTANCE_SHIFT 17 // scale the distance metric for a branch
//---- modulation parameters ---------------------------------------------
#define BITS_PER_SYMBOL 2 // number of bits per symbol
#if COMPILE_MODE == MEX_COMPILE
#define PRE_IFFT_SCALE 14 // shift ifft data left this many bits
#define DATA_IFFT_SCALE 14 // same deal
#define IMP_IFFT_SCALE 1 // shift carrier left this much when calc'ing impulse resp
#define IFFT_SCALE 0 // scale FFT output by 1/FFT_LEN or not
#define FFT_SCALE 1 // scale FFT output by 1/FFT_LEN
#else // DSP_COMPILE
#define PRE_IFFT_SCALE 8 // shift ifft data left this many bits
#define DATA_IFFT_SCALE 8 // same deal
#define IMP_IFFT_SCALE -4 // shift carrier left this much when calc'ing impulse resp
#define IFFT_SCALE 0 // scale FFT output by 1/FFT_LEN or not
#define FFT_SCALE 1 // scale FFT output by 1/FFT_LEN
#endif
//---- AGC parameters --------------------------------------------------------------
// initial register value 7
#define AGC_INTERVAL 16 // Get interupted every n samples and calc new AGC gain
#define NUM_ALIGN_FRAMES 5 // # of frames to ave to do frame align
#define FFT_LEN_SHORT 64 // samples for short FFT
#define ADC_CLIP_LEVEL 0x7FFF // modeled 13bit ADC clip level
#define ADC_READ_SHIFT 2 // Amount to shift read-in word
#define AGC_CTRL_MAX 7 // max AFE1230 RXPGA register value
#define AGC_CTRL_MIN 0 // min AFE1230 RXPGA register value
#define AGC_CTRL_SHIFT 10 // amount to right shift AGC control gain
#define AGC_CTRL_HALF 512 // Add to control var to correct for trunc after shift
#define AGC_THRS_LO_IDLE 0x1500 // 16.4%
#define AGC_THRS_HI_IDLE 0x3000 // 37.5%
#define AGC_THRS_LO_PRE 0x2000 // 25.0%
#define AGC_THRS_HI_PRE 0x4000 // 50.0%
#define AGC_INIT_GAIN 7168 // initial log agc gain
#define AGC_OVERFLOW_COUNT 300 // allow this many overflows per packet
//---- Packet Detect parameters -------------------------------------------------------------
// double difference phase high thr 47% // Do an fft every n samples to see if its preamble
// lo 20% // Do an fft every n samples to see if its preamble
// FFT measurements per frame 4 // Do an fft every n samples to see if its preamble
#define SNR_FFT_INTERVAL 64
#define SNR_PRE_DET_COUNT 4 // # of fft intervals to see before holding
#define DDPHASE_MSHIFT 8 // double-difference phase calc scale
#define DDPHASE_HI_LIM 38 // upper and lower thresholds for preamble detect
#define DDPHASE_LO_LIM 16 //
//---- Frame Align parameters --------------------------------------------------------------
// Align done % of CARRIER_LEN 55% //
#define PHASE_MEAS_LEN 5 // number of subcarriers to use to compare phase
#define ALIGN_DONE_CRITERIA 22 // Criteria for desiding if we've run into the sync field
#define WORST_PWR_LIMIT 33 // check for low SNR
#define PWR_SCALE_SHIFT 10 // num fraction bits
#define CARRIER_SCALE 13 // num fraction bits
#define PWR_SHIFT 10 // num fraction bits
#define FEQ_SHIFT 8 // num fraction bits
#endif // OFDM_MODEM_CONST_H Header file guard
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -