Skip to content

Commit 68a9302

Browse files
committed
Fix off-by-one typo
1 parent e200ee8 commit 68a9302

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cores/nRF5/Tone.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ bool TONE_PWM_CONFIG::InitializeFromPulseCountAndTimePeriod(uint64_t pulse_count
309309
// split the number of bits between refresh and loop_count in 2:1 ratio
310310
// so that, no matter what inputs are given, guaranteed to have interrupt-free solution
311311
unsigned int bits_for_refresh = bits_needed * 2 / 3; // range is [1 .. 24]
312-
unsigned int bits_for_loop_count = bits_needed - bits_for_refresh; // range is [1 .. 13]
312+
//unsigned int bits_for_loop_count = bits_needed - bits_for_refresh; // range is [1 .. 13]
313313

314314
// NOTE: Due to final SEQ1 outputting exactly one pulse, may need one additional bit for loop count
315315
// ... but that will still be within the 16 bits available, because top of range is 13 bits.
@@ -371,10 +371,11 @@ bool TONE_PWM_CONFIG::ApplyConfiguration(uint32_t pin) noexcept {
371371
// static sequence value ... This is the value actually used
372372
// during playback ... do NOT modify without semaphore *and*
373373
// having ensured playback has stopped!
374-
static uint16_t seq_values[1] = { this->duty_with_polarity };
374+
static uint16_t seq_values; // static value
375+
seq_values = this->duty_with_polarity;
375376

376-
nrf_pwm_seq_ptr_set(_PWMInstance, 0, &seq_values[0]);
377-
nrf_pwm_seq_ptr_set(_PWMInstance, 1, &seq_values[0]);
377+
nrf_pwm_seq_ptr_set(_PWMInstance, 0, &seq_values);
378+
nrf_pwm_seq_ptr_set(_PWMInstance, 1, &seq_values);
378379
nrf_pwm_seq_cnt_set(_PWMInstance, 0, 1);
379380
nrf_pwm_seq_cnt_set(_PWMInstance, 1, 1);
380381

0 commit comments

Comments
 (0)