How do I get started programming for Teensy... without using any libraries?
I've made and flashed sketches to Teensy 3.2 (and Arduino Mega) using the Arduino IDE, and I also feel that I know C++ well enough to build desktop command line utilities.
I want to learn microcontroller programming, but I feel like I am missing "basic" information about what is going on because the Arduino tools and libraries are hiding things and doing things automatically, and I want to understand what is actually going on.
For desktop C++, I'm using CodeLite on Debian 11 with the GCC compiler.
And what I would like to do, as a learning exercise, if possible, is write the simplest program possible (for a Teensy 3.2) that blinks a pixel on an OLED, but using the following rules:
1. Write code using only .cpp and .h files. No .ino or Arduino specific files.
2. If possible, compile the code without using the Arduino IDE. Can I just use GCC in Codelite (or command line) to cross compile a flashable .hex?
3. Existing Teensy or Arduino headers or libraries are NOT allowed. No Arduino.h or anything else.
4. Any C++ standard library ie. std::array, std::vector, etc IS allowed. (if it works on ARM Cortex processors)
I'm interested in working only at the C++ (or maybe C) level, no assembler, but I want to avoid using frameworks and libraries so I understand how the code I write actually talks to the microcontroller without framework abstraction.
I don't think pinMode() and digitalWriteFast() actually exist in the chip. There's probably something else going on, at the C++ level to make these functions work, that are being hidden away by the Arduino framework.
And I want to understand what is happening at that level.
So I want to write the most basic program possible that initializes the ARM Cortex, and instructs it to communicate over SPI to a SH1106 OLED controller IC, *without* using existing libraries that hide how the protocol works, or hide what actually needs to be done to work with a microcontroller directly.
Unfortunately, it's hard to get information on this, because everything "Arduino" seems to be based on opening the Arduino IDE and including SomoneElsesLibrary.h. I've been searching a lot online, but only finding bits and pieces of information.
I've also tried looking at source code, but there's lots of arrays or structs full of hex values, without any explanation of what those values actually do. I can recognize a bitshift operator, but that doesn't help me learn what's happening without understanding what is actually being shifted and why. (Because bits only have meaning when they represent things that are known).
I think there's several separate things that I need to figure out, and I would appreciate if anyone could point me to resources on them:
1. What tools do I need for a Linux based C++ to ARM workflow, (without using Arduino tools like the Arduino IDE)? Assume that I have built Linux command line programs for Linux x86_64 in CodeLite with GCC, and have flashed Teensy/Arduino from the Arduino IDE, but have no other microcontroller experience. (I don't know how to cross-compile, but I know it's a thing).
2. Where can I get the data sheet that I need for the ARM Cortex M4? I went to ARM's website and got several PDF's, and they are technical, but I don't think they are meant for software programmers. Is there documentation that lists the basic instructions that C++ can "send" to the chip? I'm honestly not sure how that works. If I want to tell a pin to go high, there has to be something in my code that tells the chip to do that, and I doubt that its pretty function like "DigitalWrite()". I'm sure there's a list of chip-level functions somewhere and how to invoke them from code.
I have a Teensy 3.2 on a PCB with a known working SH1106 OLED. I've tested it with known working firmware (built in the Arduino IDE) and the hardware is fine. Now I want to erase it and start from scratch. Actual scratch. Because I think it's important to learn how these chips actually work, and how SPI actually works, without the abstractions that come from other people's libraries and frameworks.
I'm sure there's already information out there on this, but I'm not finding a comprehensive source for the information I need.
I've made and flashed sketches to Teensy 3.2 (and Arduino Mega) using the Arduino IDE, and I also feel that I know C++ well enough to build desktop command line utilities.
I want to learn microcontroller programming, but I feel like I am missing "basic" information about what is going on because the Arduino tools and libraries are hiding things and doing things automatically, and I want to understand what is actually going on.
For desktop C++, I'm using CodeLite on Debian 11 with the GCC compiler.
And what I would like to do, as a learning exercise, if possible, is write the simplest program possible (for a Teensy 3.2) that blinks a pixel on an OLED, but using the following rules:
1. Write code using only .cpp and .h files. No .ino or Arduino specific files.
2. If possible, compile the code without using the Arduino IDE. Can I just use GCC in Codelite (or command line) to cross compile a flashable .hex?
3. Existing Teensy or Arduino headers or libraries are NOT allowed. No Arduino.h or anything else.
4. Any C++ standard library ie. std::array, std::vector, etc IS allowed. (if it works on ARM Cortex processors)
I'm interested in working only at the C++ (or maybe C) level, no assembler, but I want to avoid using frameworks and libraries so I understand how the code I write actually talks to the microcontroller without framework abstraction.
I don't think pinMode() and digitalWriteFast() actually exist in the chip. There's probably something else going on, at the C++ level to make these functions work, that are being hidden away by the Arduino framework.
And I want to understand what is happening at that level.
So I want to write the most basic program possible that initializes the ARM Cortex, and instructs it to communicate over SPI to a SH1106 OLED controller IC, *without* using existing libraries that hide how the protocol works, or hide what actually needs to be done to work with a microcontroller directly.
Unfortunately, it's hard to get information on this, because everything "Arduino" seems to be based on opening the Arduino IDE and including SomoneElsesLibrary.h. I've been searching a lot online, but only finding bits and pieces of information.
I've also tried looking at source code, but there's lots of arrays or structs full of hex values, without any explanation of what those values actually do. I can recognize a bitshift operator, but that doesn't help me learn what's happening without understanding what is actually being shifted and why. (Because bits only have meaning when they represent things that are known).
I think there's several separate things that I need to figure out, and I would appreciate if anyone could point me to resources on them:
1. What tools do I need for a Linux based C++ to ARM workflow, (without using Arduino tools like the Arduino IDE)? Assume that I have built Linux command line programs for Linux x86_64 in CodeLite with GCC, and have flashed Teensy/Arduino from the Arduino IDE, but have no other microcontroller experience. (I don't know how to cross-compile, but I know it's a thing).
2. Where can I get the data sheet that I need for the ARM Cortex M4? I went to ARM's website and got several PDF's, and they are technical, but I don't think they are meant for software programmers. Is there documentation that lists the basic instructions that C++ can "send" to the chip? I'm honestly not sure how that works. If I want to tell a pin to go high, there has to be something in my code that tells the chip to do that, and I doubt that its pretty function like "DigitalWrite()". I'm sure there's a list of chip-level functions somewhere and how to invoke them from code.
I have a Teensy 3.2 on a PCB with a known working SH1106 OLED. I've tested it with known working firmware (built in the Arduino IDE) and the hardware is fine. Now I want to erase it and start from scratch. Actual scratch. Because I think it's important to learn how these chips actually work, and how SPI actually works, without the abstractions that come from other people's libraries and frameworks.
I'm sure there's already information out there on this, but I'm not finding a comprehensive source for the information I need.