arduinocc
Published © LGPL

Arduino Nano 33 IoT Debugging

Get your Nano 33 IoT board connected to full GDB debugging so you can solve those bugs and get your project released!

AdvancedFull instructions provided11,997
Arduino Nano 33 IoT Debugging

Things used in this project

Hardware components

Arduino Nano 33 IoT
Arduino Nano 33 IoT
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
(can just cut 3 in half)
×5
Segger J-Link Probe
×1

Software apps and online services

Arduino IDE
Arduino IDE
Visual Studio 2017
Microsoft Visual Studio 2017
Visual Micro

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Solder Flux, Soldering
Solder Flux, Soldering
(may be in your solder already)

Story

Read more

Schematics

Arduino Nano 33 IoT to Debugger Wiring

Example of how to wire the Arduino Nano 33 IoT to an external debugger.

The header shown is from the Segger JLINK and we are using it in SWD mode here.

Code

Nano33IoTProject.ino

Arduino
Main Sketch file used in video
const int motor = 12;
int currentMotorPWM = 0;
unsigned long currentPeriodStartTime = 0;
unsigned int currentPeriod_MS = 1000;
unsigned int currentResolution = 254;
unsigned int maxResolution = 254;
int currentPWMVal = 0;
unsigned long loopCounter = 0;

void setup() {
	pinMode(motor, OUTPUT);
	analogWrite(motor, currentPWMVal);
}

void loop() {
	currentPWMVal = calculateCurrentPWM_sine((millis() - currentPeriodStartTime) % currentPeriod_MS);
	pwmWrite(currentPWMVal);
	loopCounter++;
}

Calcs.ino

Arduino
Secondary INO sketch used in Debugger video
// Encapsualtion 
int calculateCurrentPWM_spiky(unsigned long periodTime) {
	return calculateCurrentPWMMultiplier(periodTime) * currentResolution;
}

int calculateCurrentPWM_sine(unsigned long periodTime) {
	return
		round(
			abs(int(
			(
				sin(
				(
					double(calculateCurrentPWM_spiky(periodTime))
					/ 165.00
					)
				)
				)
				* double(currentResolution)
				)
			)
		);
}


int oldValue = -1;
void pwmWrite(int value) {
	if (oldValue != value) {
		analogWrite(motor, value);
		oldValue = value;
		Serial.print(",");
		Serial.print(value);
	}
}

double calculateCurrentPWMMultiplier(unsigned long periodTime) {
	if ((double(periodTime % currentPeriod_MS) / double((currentPeriod_MS / 2.00))) <= 1.00) {
		return (double(periodTime % currentPeriod_MS) / double((currentPeriod_MS / 2.00)));
	}
	else {
		return (1.00 - ((double(periodTime % currentPeriod_MS) - double((currentPeriod_MS / 2.00))) / double((currentPeriod_MS / 2.00))));
	}
}

Credits

arduinocc

arduinocc

2 projects • 13 followers

Comments