frequency est. We combine samples from either end of frame to
improve estimate. Small real 1E-12 term to prevent instability
with 0 inputs. */
-
+
*foff_est = Fs1 * cargf(conjf(p1)*p2 + conjf(p3)*p4 + 1E-12f) / TAU;
return timing_est;
ofdm->timing_valid = 0;
ofdm->timing_mx = 0.0f;
ofdm->nin = OFDM_SAMPLESPERFRAME;
-
+ ofdm->foff_running = 0.0 + I*0.0;
+
/* sync state machine */
strcpy(ofdm->sync_state,"searching");
we use a Unique Word to get a really solid indication of sync. */
ofdm->uw_errors = 0;
+ int tx_uw[] = {1,0,0,1,0,1,0,0,1,0};
for (i=0; i<OFDM_NUWBITS; i++) {
- ofdm->uw_errors += rx_uw[i];
+ ofdm->uw_errors += tx_uw[i] ^ rx_uw[i];
}
/* during trial sync we don't tolerate errors so much, we look
strcpy(ofdm->sync_state_interleaver, "searching");
}
- if (ofdm->frame_count == 3) {
+ if (ofdm->frame_count == 4) {
/* three good frames, sync is OK! */
strcpy(next_state, "synced");
}
if (ofdm->uw_errors > 2) {
ofdm->sync_counter++;
} else {
- if (ofdm->sync_counter) {
- ofdm->sync_counter--;
- }
+ ofdm->sync_counter = 0;
}
if (ofdm->sync_counter == 6) {
symbols_to_llrs(llr, codeword_symbols_de, codeword_amps_de, EsNo, CODED_SYMSPERFRAME);
iter = run_ldpc_decoder(&ldpc, out_char, llr, &parityCheckCount);
Nerrs = DATA_BITSPERFRAME - parityCheckCount;
- fprintf(stderr, "iter: %d pcc: %d Nerrs: %d\n", iter, parityCheckCount, Nerrs);
+ //fprintf(stderr, "iter: %d pcc: %d Nerrs: %d\n", iter, parityCheckCount, Nerrs);
if (Nerrs < 10) {
/* sucessful decode! */
strcpy(next_sync_state_interleaver, "synced");
int rx_bits_raw[CODED_BITSPERFRAME];
for (j=0; j<interleave_frames; j++) {
for(i=0; i<CODED_SYMSPERFRAME; i++) {
- complex float s = codeword_symbols_de[j*CODED_SYMSPERFRAME+i].real + I*codeword_symbols_de[j*CODED_SYMSPERFRAME+i].imag;
- qpsk_demod(s, &rx_bits_raw[OFDM_BPS*i]);
+ int bits[2];
+ complex float s = codeword_symbols_de[j*CODED_SYMSPERFRAME+i].real + I*codeword_symbols_de[j*CODED_SYMSPERFRAME+i].imag;
+ qpsk_demod(s, bits);
+ rx_bits_raw[OFDM_BPS*i] = bits[1];
+ rx_bits_raw[OFDM_BPS*i+1] = bits[0];
}
Nerrs = 0;
+ assert(sizeof(test_codeword)/sizeof(int) == CODED_BITSPERFRAME);
for(i=0; i<CODED_BITSPERFRAME; i++) {
- //fprintf(stderr, "%d %d %d\n", i, test_bits_ofdm[i], rx_bits_raw[i]);
- if (test_bits_ofdm[i] != rx_bits_raw[i]) {
+ //fprintf(stderr, "%d %d %d\n", i, test_codeword[i], rx_bits_raw[i]);
+ if (test_codeword[i] != rx_bits_raw[i]) {
Nerrs++;
}
}
+
Nerrs_raw += Nerrs;
}
Terrs += Nerrs_raw;
- Tbits += Nbitsperframe;
+ Tbits += Nbitsperframe*interleave_frames;
}
for (j=0; j<interleave_frames; j++) {