Great job on accomplishing this complex procedure!
You only need to perform a "Burn Bootloader" operation under one of the following conditions:
- You are working with a new microcontroller. In this case, the chip's fuses will be configured according to the factory defaults, which might be different from the configuration you want.
- You changed one of the relevant options from the menus under Arduino IDE's Tools menu. Some of these options define fuse configurations, and so will only take effect after you perform a "Burn Bootloader" operation.
But you don't need to perform a "Burn Bootloader" operation if you only changed something in the sketch code. In this case you can simply perform an "Upload Using Programmer" operation.
If you are uploading to the ATtiny24 frequently, you might like to know that you can also just click the "Upload" button on the Arduino IDE toolbar, just like you would when uploading a sketch to the UNO R4 Minima board. The "ATtiny24/44/84(a) (No bootloader)" board definition of ATTinyCore is configured so that clicking the "Upload" button performs an "Upload Using Programmer" operation. So clicking the button is functionally equivalent to selecting Sketch > Upload Using Programmer, but slightly more convenient.
Not normal, but it is appropriate in this particular case.
Every C++/C program must have a main
function. In the Arduino world, this function is hidden away in the core of each Arduino boards platform. For example, you can see the main
function in the "ATTinyCore" platform's core here:
Note that this main
function calls a function named setup
:
and another function named loop
:
These functions are expected to be defined in the user's code in the sketch. This system is intended to make it easier for beginners to get started with Arduino by allowing them to avoid having to implement the code for an infinite loop that most any embedded systems program will use:
However, it is possible for us to circumvent that convenience system if we like, and instead define our own main
function in the sketch program. If this is done, it overrides the main
function defined by the core.
Since the "OTTS-NP" program is just a pure C program; not dependent on the Arduino build system and core, a main
function is defined in that OTTS-NP.c
file:
int main(void)
{
[...]
and this is a complete program without any need for additional code in the .ino
file.
However, if you like, you are welcome to add code to OTTS-NP.ino
. You could probably even copy all the code from OTTS-NP.c
to OTTS-NP.ino
and delete OTTS-NP.c
. OTTS-NP.c
is written in the C programming language, and the .c
file extension causes it to be compiled as C by the Arduino sketch build system. Conversely, we use the "Arduino programming language" (essentially C++) in .ino
files, and the sketch build system compiles the code in .ino
files as such. However, C++ is a superset of C, so it is likely that the code in OTTS-NP.c
will work just as well if it was moved to OTTS-NP.ino
.
If you are going to add your own code, keep in mind that the main
function defined in the OTTS-NP.c
code does not call setup
and loop
functions, so if you try to write the sketch code as usual by putting it in functions with those names, your code won't ever be executed (unless you added setup()
and loop()
calls to the program's main
function).