arduinocc
Published © GPL3+

Arduino Uno Debugging

Try GDB debugging on your Arduino Uno without an external debugger, so you can solve those bugs and get your project released!

BeginnerFull instructions provided20,179
Arduino Uno Debugging

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×4
SparkFun USB to Serial Breakout - FT232RL
SparkFun USB to Serial Breakout - FT232RL
×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)
Only IF needed for Breakout Board
Solder Wire, Lead Free
Solder Wire, Lead Free
Only IF needed for Breakout Board

Story

Read more

Schematics

Uno to USB Serial Breakout Wiring

Shows how to wire a USB Serial converter to the Uno for this example.

Code

GDBStubExample.ino

Arduino
Main GDBStub Sketch Example used in this tutorial
#ifdef _DEBUG
#include <SoftwareSerial.h>
#include <avr8-stub.h>
#include <app_api.h>

	#define USE_SERIAL SWSerial
	SoftwareSerial SWSerial(2, 3);
#else
	#define USE_SERIAL Serial
#endif

double currentSinVal = 0.0;
double currentCosVal = 0.0; 
int randomVal = 0;



void setup() {
#ifdef _DEBUG
	debug_init();
#endif

	USE_SERIAL.begin(115200);

	randomSeed(millis());
}

void loop() {
#ifdef _DEBUG
	breakpoint();
#endif
	currentSinVal = getSinValue(millis());
	currentCosVal = getCosValue(millis());
	randomVal += random(0, 100);

	USE_SERIAL.println(randomVal);

}

Calcs.ino

Arduino
Secondary code file used in examples
double getSinValue(unsigned long millis) {
	double newSin = 1+ sin(millis / 200);
	return newSin * 90;
}

double getCosValue(unsigned long millis) {
	double newCos = cos(millis / 200);
	return newCos * 90;
}

Credits

arduinocc
5 projects • 13 followers
Arduino compatible IDE for Microsoft Visual Studio and Atmel Studio 7 with unique USB Debugger, Trace, Pin Viewer and Plotter, GDB Debugging
Contact

Comments

Please log in or sign up to comment.