1212 Therefore, their executions are not blocked by bad-behaving functions / tasks.
1313 This important feature is absolutely necessary for mission-critical tasks.
1414
15- Version: 1.1.2
15+ Version: 1.1.3
1616
1717 Version Modified By Date Comments
1818 ------- ----------- ---------- -----------
1919 1.0.0 K.Hoang 23/08/2022 Initial coding to support AVR Dx (AVR128Dx, AVR64Dx, AVR32Dx, etc.) using DxCore
2020 1.1.0 K.Hoang 24/08/2022 Improve and customize examples for Curiosity Nano AVRDA/AVRDB boards
2121 1.1.1 K.Hoang 24/08/2022 Using Serial1 instead of Serial for debugging with Curiosity Nano AVRDA/AVRDB
2222 1.1.2 K.Hoang 24/08/2022 Using Serial3 for debugging with Curiosity Nano AVRDB
23+ 1.1.3 K.Hoang 27/08/2022 Fix TCB0 disable bug
2324****************************************************************************************************************************/
2425
2526#pragma once
@@ -168,17 +169,7 @@ void TimerInterrupt::init(const int8_t& timer)
168169 TimerTCB [timer ]-> CCMP = MAX_COUNT_16BIT ; // Value to compare with.
169170 TimerTCB [timer ]-> INTCTRL &= ~TCB_CAPT_bm ; // Disable the interrupt
170171 TimerTCB [timer ]-> CTRLA = TCB_CLKSEL_VALUE | TCB_ENABLE_bm ; // Use Timer A as clock, enable timer
171-
172- TISR_LOGWARN1 (F ("TCB" ), timer );
173172
174- TISR_LOGINFO (F ("==================" ));
175- TISR_LOGINFO1 (F ("Init, Timer = " ), timer );
176- TISR_LOGINFO1 (F ("CTRLB = " ), TimerTCB [timer ]-> CTRLB );
177- TISR_LOGINFO1 (F ("CCMP = " ), TimerTCB [timer ]-> CCMP );
178- TISR_LOGINFO1 (F ("INTCTRL = " ), TimerTCB [timer ]-> INTCTRL );
179- TISR_LOGINFO1 (F ("CTRLA = " ), TimerTCB [timer ]-> CTRLA );
180- TISR_LOGINFO (F ("==================" ));
181-
182173 _timer = timer ;
183174
184175 interrupts ();
@@ -201,15 +192,7 @@ void TimerInterrupt::set_CCMP()
201192 TimerTCB [_timer ]-> CCMP = _CCMPValueToUse ; // Value to compare with.
202193
203194 TimerTCB [_timer ]-> INTCTRL = TCB_CAPT_bm ; // Enable the interrupt
204-
205- TISR_LOGDEBUG (F ("==================" ));
206- TISR_LOGDEBUG1 (F ("set_CCMP, Timer = " ), _timer );
207- TISR_LOGDEBUG1 (F ("CTRLB = " ), TimerTCB [_timer ]-> CTRLB );
208- TISR_LOGDEBUG1 (F ("CCMP = " ), TimerTCB [_timer ]-> CCMP );
209- TISR_LOGDEBUG1 (F ("INTCTRL = " ), TimerTCB [_timer ]-> INTCTRL );
210- TISR_LOGDEBUG1 (F ("CTRLA = " ), TimerTCB [_timer ]-> CTRLA );
211- TISR_LOGDEBUG (F ("==================" ));
212-
195+
213196 // Flag _CCMPValue == 0 => end of long timer
214197 if (_CCMPValueRemaining == 0 )
215198 _timerDone = true;
@@ -226,10 +209,8 @@ bool TimerInterrupt::setFrequency(const float& frequency, timer_callback_p callb
226209 float frequencyLimit = frequency * 17179.840 ;
227210
228211 // Limit frequency to larger than (0.00372529 / 64) Hz or interval 17179.840s / 17179840 ms to avoid uint32_t overflow
229- if ((_timer <= 0 ) || (callback == NULL ) || ((frequencyLimit ) < 1 ) )
230- {
231- TISR_LOGDEBUG (F ("setFrequency error" ));
232-
212+ if ((_timer < 0 ) || (callback == NULL ) || ((frequencyLimit ) < 1 ) )
213+ {
233214 return false;
234215 }
235216 else
@@ -238,14 +219,9 @@ bool TimerInterrupt::setFrequency(const float& frequency, timer_callback_p callb
238219 if (duration > 0 )
239220 {
240221 _toggle_count = frequency * duration / 1000 ;
241-
242- TISR_LOGINFO1 (F ("setFrequency => _toggle_count = " ), _toggle_count );
243- TISR_LOGINFO3 (F ("Frequency =" ), frequency , F (", duration = " ), duration );
244222
245223 if (_toggle_count < 1 )
246- {
247- TISR_LOGDEBUG (F ("setFrequency: _toggle_count < 1 error" ));
248-
224+ {
249225 return false;
250226 }
251227 }
@@ -265,9 +241,6 @@ bool TimerInterrupt::setFrequency(const float& frequency, timer_callback_p callb
265241 _timerDone = false;
266242
267243 _CCMPValue = _CCMPValueRemaining = (uint32_t ) (CLK_TCB_FREQ / frequency );
268-
269- TISR_LOGINFO3 (F ("Frequency = " ), frequency , F (", CLK_TCB_FREQ = " ), CLK_TCB_FREQ );
270- TISR_LOGINFO1 (F ("setFrequency: _CCMPValueRemaining = " ), _CCMPValueRemaining );
271244
272245 // Set the CCMP for the given timer,
273246 // set the toggle count,
@@ -381,9 +354,7 @@ void TimerInterrupt::resumeTimer()
381354 if (countLocal != 0 )
382355 {
383356 if (ITimer0 .checkTimerDone ())
384- {
385- TISR_LOGDEBUG3 (F ("T0 callback, _CCMPValueRemaining = " ), ITimer0 .get_CCMPValueRemaining (), F (", millis = " ), millis ());
386-
357+ {
387358 ITimer0 .callback ();
388359
389360 if (ITimer0 .get_CCMPValue () > MAX_COUNT_16BIT )
@@ -404,9 +375,7 @@ void TimerInterrupt::resumeTimer()
404375 }
405376 }
406377 else
407- {
408- TISR_LOGWARN (F ("T0 done" ));
409-
378+ {
410379 ITimer0 .detachInterrupt ();
411380 }
412381 }
@@ -437,9 +406,7 @@ void TimerInterrupt::resumeTimer()
437406 if (countLocal != 0 )
438407 {
439408 if (ITimer1 .checkTimerDone ())
440- {
441- TISR_LOGDEBUG3 (F ("T1 callback, _CCMPValueRemaining = " ), ITimer1 .get_CCMPValueRemaining (), F (", millis = " ), millis ());
442-
409+ {
443410 ITimer1 .callback ();
444411
445412 if (ITimer1 .get_CCMPValue () > MAX_COUNT_16BIT )
@@ -461,8 +428,6 @@ void TimerInterrupt::resumeTimer()
461428 }
462429 else
463430 {
464- TISR_LOGWARN (F ("T1 done" ));
465-
466431 ITimer1 .detachInterrupt ();
467432 }
468433 }
@@ -491,9 +456,7 @@ void TimerInterrupt::resumeTimer()
491456 if (countLocal != 0 )
492457 {
493458 if (ITimer2 .checkTimerDone ())
494- {
495- TISR_LOGDEBUG3 (F ("T2 callback, _CCMPValueRemaining = " ), ITimer2 .get_CCMPValueRemaining (), F (", millis = " ), millis ());
496-
459+ {
497460 ITimer2 .callback ();
498461
499462 if (ITimer2 .get_CCMPValue () > MAX_COUNT_16BIT )
@@ -514,9 +477,7 @@ void TimerInterrupt::resumeTimer()
514477 }
515478 }
516479 else
517- {
518- TISR_LOGWARN (F ("T2 done" ));
519-
480+ {
520481 ITimer2 .detachInterrupt ();
521482 }
522483 }
@@ -545,9 +506,7 @@ void TimerInterrupt::resumeTimer()
545506 if (countLocal != 0 )
546507 {
547508 if (ITimer3 .checkTimerDone ())
548- {
549- TISR_LOGDEBUG3 (F ("T3 callback, _CCMPValueRemaining = " ), ITimer3 .get_CCMPValueRemaining (), F (", millis = " ), millis ());
550-
509+ {
551510 ITimer3 .callback ();
552511
553512 if (ITimer3 .get_CCMPValue () > MAX_COUNT_16BIT )
@@ -568,9 +527,7 @@ void TimerInterrupt::resumeTimer()
568527 }
569528 }
570529 else
571- {
572- TISR_LOGWARN (F ("T3 done" ));
573-
530+ {
574531 ITimer3 .detachInterrupt ();
575532 }
576533 }
@@ -600,9 +557,7 @@ void TimerInterrupt::resumeTimer()
600557 if (countLocal != 0 )
601558 {
602559 if (ITimer4 .checkTimerDone ())
603- {
604- TISR_LOGDEBUG3 (F ("T4 callback, _CCMPValueRemaining = " ), ITimer4 .get_CCMPValueRemaining (), F (", millis = " ), millis ());
605-
560+ {
606561 ITimer4 .callback ();
607562
608563 if (ITimer4 .get_CCMPValue () > MAX_COUNT_16BIT )
@@ -623,9 +578,7 @@ void TimerInterrupt::resumeTimer()
623578 }
624579 }
625580 else
626- {
627- TISR_LOGWARN (F ("T4 done" ));
628-
581+ {
629582 ITimer4 .detachInterrupt ();
630583 }
631584 }
0 commit comments