File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ uint8_t tone_init = 0;
50
50
51
51
static int8_t toneBegin ( uint8_t _pin )
52
52
{
53
- int8_t i = - 1 ;
53
+ int8_t i;
54
54
55
55
// check all arrays initialised
56
56
if ( tone_init == 0 )
@@ -80,7 +80,7 @@ return ( i < NUM_TONE_PINS ) ? i : -1;
80
80
}
81
81
82
82
83
- // frequency (in hertz) and duration (in milliseconds).
83
+ // Frequency (in hertz) and duration (in milliseconds).
84
84
// Max frequency usable = 500 Hz
85
85
// Min frequency usable = 1 Hz
86
86
// Duration default of 0 for permanently on
@@ -101,7 +101,7 @@ if( frequency > 0 && frequency <= 500 )
101
101
timer_toggle_count[ _timer ] = 2 * frequency * duration/1000 ;
102
102
else
103
103
timer_toggle_count[ _timer ] = -1 ; // Continuous
104
- // Set int task parameters
104
+ // Set internal task parameters
105
105
setParam ( _timer, _timer );
106
106
setInterval ( _timer, (unsigned int )FREQUENCY_TO_MILLIS ( frequency ) );
107
107
startTask ( _timer );
@@ -113,7 +113,7 @@ if( frequency > 0 && frequency <= 500 )
113
113
// Stops tone at next 1ms Systick
114
114
void noTone ( uint8_t _pin )
115
115
{
116
- int8_t i = - 1 ;
116
+ int8_t i;
117
117
118
118
for ( i = 0 ; i < NUM_TONE_PINS; i++ )
119
119
if ( tone_pins[ i ] == _pin )
Original file line number Diff line number Diff line change @@ -161,7 +161,10 @@ int (* tasks[_MAX_TASKS])( int, int16_t );
161
161
struct TaskList taskTable [ _MAX_TASKS ];
162
162
163
163
unsigned long old_ms = 0 ; // last execution time
164
- int running ; // Current task ID being checked or run
164
+ int running = _MAX_TASKS ; // Current task ID being checked or run
165
+ // Initialise to avoid fast CPU EXTREME edge case of
166
+ // requesting task (mainly first Tone task) BEFORE the
167
+ // FIRST SysTick interrupt (1 ms) after power up.
165
168
166
169
/* SysTick counter */
167
170
volatile uint32_t g_systick_count = 0U ;
You can’t perform that action at this time.
0 commit comments