In order to use Simple Dumping Monitor library debugger, you should add library initialization function call to the sketch's setup() function code, then also you should add variables to the watchlist.
#include <dumpmon.h> // Include DumpMon library to the sketch. #define LEDPIN 13 // LED connected to Digital 13 pin. int count = 0; // 16-bit integer counter variable. long lcount = 0; // 32-bit integer counter variable. char* text = "Debug"; // String variable. void setup() { pinMode(LEDPIN, OUTPUT); // Set up LED pin to output mode. dumpmonSetup(19200); // DumpMon library initialization. watch(&count, "count"); // Add int-type variable address to the watchlist. watch(&lcount, "lcount"); // Add long-type variable address to the watchlist. watch(&text, "text"); // Add string variable address to the watchlist. watch(&PORTB, "PORTB"); // Add register of port B address to the watchlist // (bit 5 matches Digital 13 pin). }
Function dumpmonSetup() accepts two parameters:
1 Serial port baud rate (bits per second).
* Initial debugger mode (by default it is step mode that match STEP_MODE value).
Since by default step debugger mode is used, than after reset the sketch will be executed up to the first breakpoint() function call. In order to make the sketch working as usual, not stopping at breakpoints, dumpmonSetup() function should be called with GO_MODE as secondary argument:
dumpmonSetup(19200, GO_MODE); // DumpMon library initialization.
By default the library is using Serial (DEV_USART0) port for communication. In order to use any other serial port of ATmega1280/2560 microcontrollers (either Serial1, Serial2 or Serial3), the link to given port should be added to the dumpmonSetup() function call:
dumpmonSetup(&Serial2, 19200, GO_MODE); // Инициализация библиотеки DumpMon // для коммуникации через порт Serial2