Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Once the channel symbols have been generated, it is a simple matter of transmitt
// Now transmit the channel symbols
for(i = 0; i < symbol_count; i++)
{
si5351.set_freq((freq * 100) + (tx_buffer[i] * tone_spacing), SI5351_CLK0);
si5351.set_freq((freq * 100ULL) + ((uint64_t)tx_buffer[i] * tone_spacing), SI5351_CLK0);
delay(tone_delay);
}

Expand Down Expand Up @@ -315,6 +315,19 @@ Also, a big thank you to Murray Greenman, ZL1BPU for working allowing me to pick

Changelog
---------
* v1.4.2

* Fix #32 — 2m/6m frequency overflow in the example sketch: `freq` was an
`unsigned long` (32-bit on AVR), so `(freq * 100)` overflowed at 2m
frequencies (e.g. 144,075,000 Hz → 1.44e10 > 2^32-1). The frequency math
now uses `uint64_t` throughout (also documented in the README example).
The example also notes the 2m/6m re-lock caveat (see issue #32 comments).
* Fix #21 — move the sync-vector tables to flash (PROGMEM): `jt65`, `jt9`,
`jt4` and `wspr` sync vectors and the `ft8` costas7x7/graymap tables are
now stored in flash and read back via `pgm_read_byte()`, saving ~510 bytes
of RAM on AVR (863 → 353 bytes in the smoke build). Output verified
bit-identical to the pre-change library; harness still 17/17 PASS.

* v1.4.1

* Fix FCR macro collision with Renesas RA4M1 device header (R7FA4M1AB.h):
Expand Down
13 changes: 10 additions & 3 deletions examples/Si5351JTDemo/Si5351JTDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ Si5351 si5351;
JTEncode jtencode;

// Global variables
unsigned long freq;
// uint64_t (not unsigned long) so that 2m/6m frequencies (e.g. 144,075,000 Hz)
// do not overflow when scaled by 100 in set_freq(). See issue #32.
uint64_t freq;
char message[] = "N0CALL AA00";
char call[] = "N0CALL";
char loc[] = "AA00";
Expand All @@ -103,7 +105,7 @@ void encode()
si5351.output_enable(SI5351_CLK0, 1);
digitalWrite(LED_PIN, HIGH);

// Now transmit the channel symbols
// FSQ modes: count symbols up to the terminator marker
if(cur_mode == MODE_FSQ_2 || cur_mode == MODE_FSQ_3 || cur_mode == MODE_FSQ_4_5 || cur_mode == MODE_FSQ_6)
{
uint8_t j = 0;
Expand All @@ -113,9 +115,14 @@ void encode()
symbol_count = j - 1;
}

// Now transmit the channel symbols
// 2m/6m note: above ~80 MHz the Si5351 takes longer to lock each new
// frequency; see issue #32 for the documented workaround (manual set_freq
// with a pre-computed frequency and a reduced tone delay, e.g. FT8_DELAY 156
// and JT65_DELAY 362).
for(i = 0; i < symbol_count; i++)
{
si5351.set_freq((freq * 100) + (tx_buffer[i] * tone_spacing), SI5351_CLK0);
si5351.set_freq((freq * 100ULL) + ((uint64_t)tx_buffer[i] * tone_spacing), SI5351_CLK0);
delay(tone_delay);
}

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Etherkit JTEncode
version=1.4.1
version=1.4.2
author=Jason Milldrum <[email protected]>
maintainer=Jason Milldrum <[email protected]>
sentence=Generate JT65, JT9, JT4, FT8, WSPR, and FSQ symbols on your Arduino.
Expand Down
31 changes: 17 additions & 14 deletions src/JTEncode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ void JTEncode::ft8_encode(uint8_t* codeword, uint8_t* symbols)
void JTEncode::jt65_merge_sync_vector(uint8_t * g, uint8_t * symbols)
{
uint8_t i, j = 0;
const uint8_t sync_vector[JT65_SYMBOL_COUNT] =
static const uint8_t sync_vector[JT65_SYMBOL_COUNT] PROGMEM =
{1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0,
0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1,
Expand All @@ -1475,7 +1475,7 @@ void JTEncode::jt65_merge_sync_vector(uint8_t * g, uint8_t * symbols)

for(i = 0; i < JT65_SYMBOL_COUNT; i++)
{
if(sync_vector[i])
if(pgm_read_byte(&sync_vector[i]))
{
symbols[i] = 0;
}
Expand All @@ -1490,7 +1490,7 @@ void JTEncode::jt65_merge_sync_vector(uint8_t * g, uint8_t * symbols)
void JTEncode::jt9_merge_sync_vector(uint8_t * g, uint8_t * symbols)
{
uint8_t i, j = 0;
const uint8_t sync_vector[JT9_SYMBOL_COUNT] =
static const uint8_t sync_vector[JT9_SYMBOL_COUNT] PROGMEM =
{1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1,
Expand All @@ -1499,7 +1499,7 @@ void JTEncode::jt9_merge_sync_vector(uint8_t * g, uint8_t * symbols)

for(i = 0; i < JT9_SYMBOL_COUNT; i++)
{
if(sync_vector[i])
if(pgm_read_byte(&sync_vector[i]))
{
symbols[i] = 0;
}
Expand All @@ -1514,7 +1514,7 @@ void JTEncode::jt9_merge_sync_vector(uint8_t * g, uint8_t * symbols)
void JTEncode::jt4_merge_sync_vector(uint8_t * g, uint8_t * symbols)
{
uint8_t i;
const uint8_t sync_vector[JT4_SYMBOL_COUNT] =
static const uint8_t sync_vector[JT4_SYMBOL_COUNT] PROGMEM =
{0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 1, 1, 0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,1 ,1,
0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0,
Expand All @@ -1528,14 +1528,14 @@ void JTEncode::jt4_merge_sync_vector(uint8_t * g, uint8_t * symbols)

for(i = 0; i < JT4_SYMBOL_COUNT; i++)
{
symbols[i] = sync_vector[i] + (2 * g[i]);
symbols[i] = pgm_read_byte(&sync_vector[i]) + (2 * g[i]);
}
}

void JTEncode::wspr_merge_sync_vector(uint8_t * g, uint8_t * symbols)
{
uint8_t i;
const uint8_t sync_vector[WSPR_SYMBOL_COUNT] =
static const uint8_t sync_vector[WSPR_SYMBOL_COUNT] PROGMEM =
{1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0,
1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0,
0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1,
Expand All @@ -1547,20 +1547,23 @@ void JTEncode::wspr_merge_sync_vector(uint8_t * g, uint8_t * symbols)

for(i = 0; i < WSPR_SYMBOL_COUNT; i++)
{
symbols[i] = sync_vector[i] + (2 * g[i]);
symbols[i] = pgm_read_byte(&sync_vector[i]) + (2 * g[i]);
}
}

void JTEncode::ft8_merge_sync_vector(uint8_t* symbols, uint8_t* output)
{
const uint8_t costas7x7[7] = {3, 1, 4, 0, 6, 5, 2};
const uint8_t graymap[8] = {0, 1, 3, 2, 5, 6, 4, 7};
static const uint8_t costas7x7[7] PROGMEM = {3, 1, 4, 0, 6, 5, 2};
static const uint8_t graymap[8] PROGMEM = {0, 1, 3, 2, 5, 6, 4, 7};
uint8_t i, j, k, idx;

// Insert Costas sync arrays
memcpy(output, costas7x7, 7);
memcpy(output + 36, costas7x7, 7);
memcpy(output + FT8_SYMBOL_COUNT - 7, costas7x7, 7);
for(i = 0; i < 7; i++)
{
output[i] = pgm_read_byte(&costas7x7[i]);
output[36 + i] = pgm_read_byte(&costas7x7[i]);
output[FT8_SYMBOL_COUNT - 7 + i] = pgm_read_byte(&costas7x7[i]);
}

k = 6;
for(j = 0; j < 58; ++j) // 58 data symbols
Expand All @@ -1572,7 +1575,7 @@ void JTEncode::ft8_merge_sync_vector(uint8_t* symbols, uint8_t* output)
k += 7;
}
idx = symbols[i] * 4 + symbols[i + 1] * 2 + symbols[i + 2];
output[k] = graymap[idx];
output[k] = pgm_read_byte(&graymap[idx]);
}
}

Expand Down
Loading