How is programming an Arduino different than stand

2019-01-21 17:47发布

问题:

I have a background in programming embedded systems (TI MSP430, Atmel ATxmega). How is programming an Arduino different than those? What knowledge about C can I take in to programming the Arduino?

回答1:

While I don't know about the ATXMega, the 8-bit AVR chips like the ATmega328 used on the newer Arduinos use the AVR-GCC compiler. This allows for compiling C and even C++ to an AVR chip. One level above the AVR-GCC is the AVR Libc, a C library that makes programming for the AVR a higher level task (no longer have to refer to registers directly, and so on).

The Arduino IDE uses AVR-GCC and AVR libc library in the backend. In addition, the Arduino IDE makes other libraries available, like a nice Serial interface.

Finally, the Arduino comes with a bootloader burned on the AVR chip. The bootloader simply makes it possible to program the AVR using a serial connection (from USB) instead of an In-Sytem Programmer or Development Board.

Enough backstory, to answer your question: The Arduino can be programmed in C and even C++. The libraries available are written in C and everything will compiled using AVR-GCC. The Arduino IDE isn't even required.

Edit

There seems to be a decent amount of interest in this topic. I wrote a blog post to try and give more in-depth details on the AVR, Arduino, and AVR-GCC.



回答2:

You can take your existing C knowledge when using Arduino.

The purpose was to allow artists/non-programmers to get started easily with hardware programming and tinkering, so the 'Arduino language' is just a wrapper to simplify development.

It should be a lot easier for you, as a C programmer to use Arduino. The documentation isn't lengthy at all, the wiki is nice and the people on the forum are enthusiastic and helpful.



回答3:

Arduino is C, except that this is inserted into every program:

void main() {
  setup();
  for(;;) {
    loop();
  }
}


回答4:

You can pretty much take all your knowledge with C and embedded systems and you will be more than OK. It's not hard to use at all. Bookmark the Arduino Reference page and you'll be writing stuff in no time.



回答5:

Arduino is C-like and extremely easy to pick up. They have abstracted away from doing things like reading and writing into peripheral registers for doing basic tasks.

One look at some example code and the Arduino reference and you'll be up and running in no time if you've actually done real C on any other platform.



标签: c++ c arduino