Arduino learned a couple of weeks ago. The professional programmer himself (Assembler IBM, Java, there is little C++ experience). I am trying to understand Arduino, but in order to understand more quickly, I decided to turn to the forum.
The task is this: Develop a sketch for Arduino Mega, debug it and test its work in some way, for example, programmatically (slip data as if from a microcontroller), but without a real microcontroller and its connection to the PC. Is it possible or not? If yes, how? If it is possible, but difficult, can it be easier to buy some kind of microcontroller?
To draw flowcharts (process logic) is no problem for me. Encode a sketch is also no problem (although a new language for me). But debugging and checking causes my questions. Naturally, I downloaded the Arduino IDE, and also installed the Arduino in my familiar NetBeans. I do the compilation without any problems and I get the “.hex” file, but how do I run it? It does not start. Requires a connection board.
There are simulators on the web; they however are not perfect. Also don't expect support for them here on the forum; you will have to get support from the creator of the simulator.
The best debugging tool is the board itself. And use of serial prints at strategic places to see what is going on; be aware that serial prints can slow down your application when the (software) output buffer is full.
Outside my area of expertise:
If you need breakpoints and the likes, I think that that is supported via the JTAG interface. See Small Guide To Arduino ATMEGA2560 JTAG Interfacing With AVRSTUDIO6. This is not supported using the Arduino IDE and more that likely also not using other IDEs.
Thanks, sterretje
Light ray in the dark kingdom. I realized that without breakpoints, the best solution is to buy the board and use Serial.println (xxx). Most likely, I will do that, but ... first I will try other options, for example, the JTAG interface.
If someone knows other debugging methods without a real board, please report
Due to the expense of the debugger combined with the lack of support for on-chip debugging in the Arduino IDE and the complexity of doing on-chip debugging, most Arduino users just stick with Serial.print for debug output.
If you download AT Studio (or whatever it's called now) from Microchip, you can set breakpoints, single-step and all that with a display that shows the state of all registers after each instruction. Big, bulky program since it was re-written for .net, but if you go back to version 4.18 when it was a stand-alone app, much quicker/smaller. You lose some boards but all the common ones are there.
You need a board to work with JTAG.
You don NOT need a board to work with the Atmel Studio Simulator.
OTOH, my experience with simulation in microcontroller environments has not been pleasant.
You're likely to spend more time setting up simulated peripherals for common Stuff that you don't really need to debug than you'd spend using a real board with print statements (and no "advanced debugging capabilities.) And you still won't have a setup that adequately models the real-time asynchonicity of a microcontroller.
Here's an adapter for connecting an Arduino MEGA to a JTAG debugger: OSH Park ~
PS: cheapest way to get real hardware debugging with an Arduino is to buy a Microchip (Atmel) "Xplained Mini 328P" board - like the Arduino Zero, it has an interface to the Atmel Studio debugger included on the board.