Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
v1.1.2 to use auto SerialDebug port
Browse files Browse the repository at this point in the history
### Release v1.1.2

1. Using `Serial3` for debugging with `Curiosity Nano AVRDB`, and `Serial1` for debugging with `Curiosity Nano AVRDA`
  • Loading branch information
khoih-prog authored Aug 25, 2022
1 parent 2a8c1cb commit 5da293e
Show file tree
Hide file tree
Showing 24 changed files with 371 additions and 232 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Release v1.1.2](#release-v112)
* [Release v1.1.1](#release-v111)
* [Release v1.1.0](#release-v110)
* [Initial Release v1.0.0](#initial-release-v100)
Expand All @@ -18,6 +19,11 @@

## Changelog

### Release v1.1.2

1. Using `Serial3` for debugging with `Curiosity Nano AVRDB`, and `Serial1` for debugging with `Curiosity Nano AVRDA`


### Release v1.1.1

1. Using Serial1 instead of Serial for debugging with Curiosity Nano AVRDA/AVRDB
Expand Down
45 changes: 27 additions & 18 deletions examples/Argument_Complex/Argument_Complex.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
#endif
#endif

#if defined(__AVR_AVR128DA48__)
#define SerialDebug Serial1
#elif defined(__AVR_AVR128DB48__)
#define SerialDebug Serial3
#else
// standard Serial
#define SerialDebug Serial
#endif

struct pinStruct
{
unsigned int Pin1;
Expand All @@ -88,19 +97,19 @@ void TimerHandler1(unsigned int outputPinsAddress)

//timer interrupt toggles pins
#if (TIMER_INTERRUPT_DEBUG > 1)
Serial1.print("Toggle pin1 = "); Serial1.println( ((pinStruct *) outputPinsAddress)->Pin1 );
SerialDebug.print("Toggle pin1 = "); SerialDebug.println( ((pinStruct *) outputPinsAddress)->Pin1 );
#endif

digitalWrite(((pinStruct *) outputPinsAddress)->Pin1, toggle);

#if (TIMER_INTERRUPT_DEBUG > 1)
Serial1.print("Read pin2 A0 ("); Serial1.print(((pinStruct *) outputPinsAddress)->Pin2 );
Serial1.print(") = ");
Serial1.println(digitalRead(((pinStruct *) outputPinsAddress)->Pin2) ? "HIGH" : "LOW" );
SerialDebug.print("Read pin2 A0 ("); SerialDebug.print(((pinStruct *) outputPinsAddress)->Pin2 );
SerialDebug.print(") = ");
SerialDebug.println(digitalRead(((pinStruct *) outputPinsAddress)->Pin2) ? "HIGH" : "LOW" );

Serial1.print("Read pin3 A1 ("); Serial1.print(((pinStruct *) outputPinsAddress)->Pin3 );
Serial1.print(") = ");
Serial1.println(digitalRead(((pinStruct *) outputPinsAddress)->Pin3) ? "HIGH" : "LOW" );
SerialDebug.print("Read pin3 A1 ("); SerialDebug.print(((pinStruct *) outputPinsAddress)->Pin3 );
SerialDebug.print(") = ");
SerialDebug.println(digitalRead(((pinStruct *) outputPinsAddress)->Pin3) ? "HIGH" : "LOW" );
#endif

toggle = !toggle;
Expand All @@ -114,32 +123,32 @@ void setup()
pinMode(myOutputPins.Pin2, INPUT_PULLUP);
pinMode(myOutputPins.Pin3, INPUT_PULLUP);

Serial1.begin(115200);
while (!Serial1 && millis() < 5000);
SerialDebug.begin(115200);
while (!SerialDebug && millis() < 5000);

Serial1.print(F("\nStarting Argument_Complex on ")); Serial1.println(BOARD_NAME);
Serial1.println(DX_TIMER_INTERRUPT_VERSION);
Serial1.print(F("CPU Frequency = ")); Serial1.print(F_CPU / 1000000); Serial1.println(F(" MHz"));
SerialDebug.print(F("\nStarting Argument_Complex on ")); SerialDebug.println(BOARD_NAME);
SerialDebug.println(DX_TIMER_INTERRUPT_VERSION);
SerialDebug.print(F("CPU Frequency = ")); SerialDebug.print(F_CPU / 1000000); SerialDebug.println(F(" MHz"));

Serial1.print(F("TCB Clock Frequency = "));
SerialDebug.print(F("TCB Clock Frequency = "));

#if USING_FULL_CLOCK
Serial1.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
SerialDebug.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
#elif USING_HALF_CLOCK
Serial1.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
SerialDebug.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
#else
Serial1.println(F("250KHz for lower accuracy but longer time"));
SerialDebug.println(F("250KHz for lower accuracy but longer time"));
#endif

// Timer TCB2 is used for micros(), millis(), delay(), etc and can't be used
CurrentTimer.init();

if (CurrentTimer.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1, (unsigned int) &myOutputPins))
{
Serial1.print(F("Starting ITimer OK, millis() = ")); Serial1.println(millis());
SerialDebug.print(F("Starting ITimer OK, millis() = ")); SerialDebug.println(millis());
}
else
Serial1.println(F("Can't set ITimer. Select another freq. or timer"));
SerialDebug.println(F("Can't set ITimer. Select another freq. or timer"));
}

void loop()
Expand Down
31 changes: 20 additions & 11 deletions examples/Argument_None/Argument_None.ino
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@
#endif
#endif

#if defined(__AVR_AVR128DA48__)
#define SerialDebug Serial1
#elif defined(__AVR_AVR128DB48__)
#define SerialDebug Serial3
#else
// standard Serial
#define SerialDebug Serial
#endif

void TimerHandler1(void)
{
static bool toggle = false;
Expand All @@ -88,32 +97,32 @@ void setup()
{
pinMode(LED_BUILTIN, OUTPUT);

Serial1.begin(115200);
while (!Serial1 && millis() < 5000);
SerialDebug.begin(115200);
while (!SerialDebug && millis() < 5000);

Serial1.print(F("\nStarting Argument_None on ")); Serial1.println(BOARD_NAME);
Serial1.println(DX_TIMER_INTERRUPT_VERSION);
Serial1.print(F("CPU Frequency = ")); Serial1.print(F_CPU / 1000000); Serial1.println(F(" MHz"));
SerialDebug.print(F("\nStarting Argument_None on ")); SerialDebug.println(BOARD_NAME);
SerialDebug.println(DX_TIMER_INTERRUPT_VERSION);
SerialDebug.print(F("CPU Frequency = ")); SerialDebug.print(F_CPU / 1000000); SerialDebug.println(F(" MHz"));

Serial1.print(F("TCB Clock Frequency = "));
SerialDebug.print(F("TCB Clock Frequency = "));

#if USING_FULL_CLOCK
Serial1.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
SerialDebug.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
#elif USING_HALF_CLOCK
Serial1.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
SerialDebug.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
#else
Serial1.println(F("250KHz for lower accuracy but longer time"));
SerialDebug.println(F("250KHz for lower accuracy but longer time"));
#endif

// Timer TCB2 is used for micros(), millis(), delay(), etc and can't be used
CurrentTimer.init();

if (CurrentTimer.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1))
{
Serial1.print(F("Starting ITimer OK, millis() = ")); Serial1.println(millis());
SerialDebug.print(F("Starting ITimer OK, millis() = ")); SerialDebug.println(millis());
}
else
Serial1.println(F("Can't set ITimer. Select another freq. or timer"));
SerialDebug.println(F("Can't set ITimer. Select another freq. or timer"));
}

void loop()
Expand Down
39 changes: 24 additions & 15 deletions examples/Argument_Simple/Argument_Simple.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
#endif
#endif

#if defined(__AVR_AVR128DA48__)
#define SerialDebug Serial1
#elif defined(__AVR_AVR128DB48__)
#define SerialDebug Serial3
#else
// standard Serial
#define SerialDebug Serial
#endif

unsigned int outputPin1 = LED_BUILTIN;

#define TIMER1_INTERVAL_MS 1000
Expand All @@ -83,8 +92,8 @@ void TimerHandler1(unsigned int outputPin = LED_BUILTIN)

#if (TIMER_INTERRUPT_DEBUG > 1)
//timer interrupt toggles pin outputPin, default LED_BUILTIN
Serial1.print("pin1 = "); Serial1.print(outputPin);
Serial1.print(" address: "); Serial1.println((uint32_t) &outputPin );
SerialDebug.print("pin1 = "); SerialDebug.print(outputPin);
SerialDebug.print(" address: "); SerialDebug.println((uint32_t) &outputPin );
#endif

digitalWrite(outputPin, toggle);
Expand All @@ -95,37 +104,37 @@ void setup()
{
pinMode(LED_BUILTIN, OUTPUT);

Serial1.begin(115200);
while (!Serial1 && millis() < 5000);
SerialDebug.begin(115200);
while (!SerialDebug && millis() < 5000);

Serial1.print(F("\nStarting Argument_Simple on ")); Serial1.println(BOARD_NAME);
Serial1.println(DX_TIMER_INTERRUPT_VERSION);
Serial1.print(F("CPU Frequency = ")); Serial1.print(F_CPU / 1000000); Serial1.println(F(" MHz"));
SerialDebug.print(F("\nStarting Argument_Simple on ")); SerialDebug.println(BOARD_NAME);
SerialDebug.println(DX_TIMER_INTERRUPT_VERSION);
SerialDebug.print(F("CPU Frequency = ")); SerialDebug.print(F_CPU / 1000000); SerialDebug.println(F(" MHz"));

Serial1.print(F("TCB Clock Frequency = "));
SerialDebug.print(F("TCB Clock Frequency = "));

#if USING_FULL_CLOCK
Serial1.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
SerialDebug.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
#elif USING_HALF_CLOCK
Serial1.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
SerialDebug.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
#else
Serial1.println(F("250KHz for lower accuracy but longer time"));
SerialDebug.println(F("250KHz for lower accuracy but longer time"));
#endif

// Timer2 is used for micros(), millis(), delay(), etc and can't be used
CurrentTimer.init();

if (CurrentTimer.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1, outputPin1))
{
Serial1.print(F("Starting ITimer OK, millis() = ")); Serial1.println(millis());
SerialDebug.print(F("Starting ITimer OK, millis() = ")); SerialDebug.println(millis());

#if (TIMER_INTERRUPT_DEBUG > 1)
Serial1.print(F("OutputPin1 = ")); Serial1.print(outputPin1);
Serial1.print(F(" address: ")); Serial1.println((uint32_t) &outputPin1 );
SerialDebug.print(F("OutputPin1 = ")); SerialDebug.print(outputPin1);
SerialDebug.print(F(" address: ")); SerialDebug.println((uint32_t) &outputPin1 );
#endif
}
else
Serial1.println(F("Can't set ITimer. Select another freq. or timer"));
SerialDebug.println(F("Can't set ITimer. Select another freq. or timer"));
}

void loop()
Expand Down
39 changes: 24 additions & 15 deletions examples/Change_Interval/Change_Interval.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,30 @@
#endif
#endif

#if defined(__AVR_AVR128DA48__)
#define SerialDebug Serial1
#elif defined(__AVR_AVR128DB48__)
#define SerialDebug Serial3
#else
// standard Serial
#define SerialDebug Serial
#endif

#define TIMER1_INTERVAL_MS 50UL

volatile uint32_t Timer1Count = 1;

void printResult(uint32_t currTime)
{
Serial1.print(F("Time = ")); Serial1.print(currTime);
Serial1.print(F(", Timer1Count = ")); Serial1.println(Timer1Count);
SerialDebug.print(F("Time = ")); SerialDebug.print(currTime);
SerialDebug.print(F(", Timer1Count = ")); SerialDebug.println(Timer1Count);
}

void TimerHandler1()
{
static bool toggle = false;

// Flag for checking to be sure ISR is working as Serial1.print is not OK here in ISR
// Flag for checking to be sure ISR is working as SerialDebug.print is not OK here in ISR
Timer1Count++;

//timer interrupt toggles pin LED_BUILTIN
Expand All @@ -99,32 +108,32 @@ void setup()
{
pinMode(LED_BUILTIN, OUTPUT);

Serial1.begin(115200);
while (!Serial1 && millis() < 5000);
SerialDebug.begin(115200);
while (!SerialDebug && millis() < 5000);

Serial1.print(F("\nStarting Change_Interval on ")); Serial1.println(BOARD_NAME);
Serial1.println(DX_TIMER_INTERRUPT_VERSION);
Serial1.print(F("CPU Frequency = ")); Serial1.print(F_CPU / 1000000); Serial1.println(F(" MHz"));
SerialDebug.print(F("\nStarting Change_Interval on ")); SerialDebug.println(BOARD_NAME);
SerialDebug.println(DX_TIMER_INTERRUPT_VERSION);
SerialDebug.print(F("CPU Frequency = ")); SerialDebug.print(F_CPU / 1000000); SerialDebug.println(F(" MHz"));

Serial1.print(F("TCB Clock Frequency = "));
SerialDebug.print(F("TCB Clock Frequency = "));

#if USING_FULL_CLOCK
Serial1.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
SerialDebug.println(F("Full clock (24/16MHz, etc) for highest accuracy"));
#elif USING_HALF_CLOCK
Serial1.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
SerialDebug.println(F("Half clock (12/8MHz, etc.) for high accuracy"));
#else
Serial1.println(F("250KHz for lower accuracy but longer time"));
SerialDebug.println(F("250KHz for lower accuracy but longer time"));
#endif

// Timer TCB2 is used for micros(), millis(), delay(), etc and can't be used
CurrentTimer.init();

if (CurrentTimer.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1))
{
Serial1.print(F("Starting ITimer OK, millis() = ")); Serial1.println(millis());
SerialDebug.print(F("Starting ITimer OK, millis() = ")); SerialDebug.println(millis());
}
else
Serial1.println(F("Can't set ITimer. Select another freq. or timer"));
SerialDebug.println(F("Can't set ITimer. Select another freq. or timer"));
}

#define CHECK_INTERVAL_MS 1000L
Expand Down Expand Up @@ -156,7 +165,7 @@ void loop()

Timer1Count++;

Serial1.print(F("Changing Interval, Timer = ")); Serial1.println(TIMER1_INTERVAL_MS * (multFactor + 1));
SerialDebug.print(F("Changing Interval, Timer = ")); SerialDebug.println(TIMER1_INTERVAL_MS * (multFactor + 1));

lastChangeTime = currTime;
}
Expand Down
Loading

0 comments on commit 5da293e

Please sign in to comment.