Does each microcontroller line have its own programming language/syntax?

I've programmed the Arduino and have started programming the Teensy. They are similar to C but there are slight nuances in the programming language.

For instance, in Arduino's C you call a function pinMode(pin#, Output/Input) to designate a digital pin to either output signals or receive signals. In Teensy's C, you set the "DDR" register associated with one of four ports (each of which represents a collection of pins) which you collectively designate as either input or output (enter link description here.

I would like to know if it is the case that when you use a microcontroller that is new to you, you need to effectively learn a new "language". I put the word "language" in quotes because despite the nuances in syntax, the components and how they are set up in software are fundamentally equivalent e.g., the notion of ports and pins still refer to a terminal from which you can output/input digital signals.

In the same vain of discourse: are there microcontrollers such as PIC10F322 http://www.kynix.com/uploadfiles/pdf8798/PIC10F322-I2fOT_206930.pdf
that aren't programmed in software or will there always be a software layer used to program the uController? If the latter, who writes/provides documentation for them?
Last edited on
Different micro-controllers have different assembler dialects, because they implement different instructions with different timing and dependency characteristics. If there is no C compiler, you'll be stuck writing a particular assembler program or encoding particular bytes.

Most vendors provide a C compiler for their common processors, and even more provide at least an assembler.

Both the Teensy and the Arduino Uno use Atmel ATMega processors which can be programmed in more or less the same way -- the difference is that by default
a. the Arduino IDE makes some basic transformations to your C++ program; and
b. the Arduino IDE links your code by default with the Arduino core library, which is a C(++)? static library.

If you dig a little bit into the Arduino core library, you'l see that pinMode() compiles into code that (among other things) sets the appropriate Data Direction Register (DDRx). With a little bit of effort you can eliminate that layer and program your processor in more-or-less standard C++: the Arduino environment's backend basically just invokes avr-g++.

Note that DDRx itself is just a (macro?) defined by some processor-specific file included from avr.h. It's essentially a reference to a particular volatile byte in the low bytes of RAM -- these processors use MMIO.

The junk in that file is basically to make programming the uC in C more bearable, but it's not necessary, and you can eliminate that too. The vendor's datasheet provides all the information you would need to do this.

(I believe I'm roughly correct with the details, but it's been several months since I last looked at this stuff, and I can't look now.)

I don't know what you mean about microcontrollers not being programmed in software.
Last edited on
closed account (48T7M4Gy)
https://www.pjrc.com/teensy/td_libs.html
Topic archived. No new replies allowed.