File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 85
85
86
86
GCLK_TC/1024:
87
87
freq = 48 MHz / prescaler = 48 MHz / 1024 = 46.875 kHz = 46875 Hz
88
- base_delay = 1 / freq = 1 / 46875 s = ~= 21, 333333333us
88
+ base_delay = 1 / freq = 1 / 46875 s = ~= 21. 333333333us
89
89
overflow_delay = UINT16_MAX * base_delay = 65535 / 46875 s = 1.39808 s
90
90
*/
91
91
152
152
_TC->CTRLA .reg &= ~TC_CTRLA_ENABLE;
153
153
while (_TC->STATUS .bit .SYNCBUSY == 1 ); // sync
154
154
155
- // Set Timer counter Mode to 16 bits + Set TC as normal Normal Frq + Prescaler: GCLK_TC/1024
156
- _TC->CTRLA .reg |= (TC_CTRLA_MODE_COUNT16 + TC_CTRLA_WAVEGEN_NFRQ + TC_CTRLA_PRESCALER_DIV1024);
155
+ // Set Timer counter Mode to 16 bits + Set TC as normal Match Frq + Prescaler: GCLK_TC/1024
156
+ _TC->CTRLA .reg |= (TC_CTRLA_MODE_COUNT16 + TC_CTRLA_WAVEGEN_MFRQ + TC_CTRLA_PRESCALER_DIV1024);
157
157
while (_TC->STATUS .bit .SYNCBUSY == 1 ); // sync
158
158
159
159
if (s > 1 ) {
160
160
__overflows = _overflows = s / 1.39808 ;
161
- __remaining = _remaining = ((s * 100000 ) % 139808 ) * 480 / 1024 ; // for integer s this is always an integer
161
+ __remaining = _remaining = ((s * 100000 ) % 139808 ) * 480 / 1024 - 1 ; // for integer s this is always an integer
162
162
} else {
163
163
__overflows = _overflows = 0 ;
164
- __remaining = _remaining = s * 46875 ;
164
+ __remaining = _remaining = s * 46875 - 1 ;
165
165
}
166
166
167
167
if (__overflows == 0 ) {
You can’t perform that action at this time.
0 commit comments