4 ms·
I've just started out with Arduino. What's the advantage of programming the AVR directly? I guess there's a bit more overhead you can remove? What are the cheap
by aidos 9y ago
I've just started out with Arduino. What's the advantage of programming the AVR directly? I guess there's a bit more overhead you can remove? What are the cheaper options? That programmer you linked to seems like a fairly expensive option for someone just looking to get started — can you still use the Arduino board as an interface to program the chip?
Edit - Bonus question: when you use something like that programmer doesn't the code/write/move-chip-into-circuit cycle become really laborious?
- forkandwait 9y agoTwo reasons for me: Real product versus toy: The arduino libraries are not the standard AVR libraries you would use to program a real product. In a real product you would also never use an arduino, too expensive and bulky. Also, the arduino ties up a bunch of pins and space compared to just the chip, for not much payoff in a typically sharp focus microcontroller use case. I think the cost for a programmer is a wash when you consider that you only need to buy bare chips after you learn how to use the programmer.
- TD-Linux 9y agoReal products absolutely do use Arduino libraries, it's not a toy. They are just embedding the AVR directly for cost (and using an external programmer), but there's no reason the Arduino libraries don't work for products that ship. Arduino only eats two pins for serial - I suppose you could drop that if you wanted, but in practice most commercial products have a debug serial port anyway.
- forkandwait 9y agoAs I understand it the Arduino libraries are big, but I have never tried. What are the advantages to not just using the AVR libraries if you are embedding the chip in the circuit and using the programmer?
- TD-Linux 9y agoFunctions you don't call get stripped out of the final binary. The advantage is you get a bunch of high level functions like analogRead() that do all the setup for you. avr-gcc/avr-libc mostly just provides register definitions, so it's likely you're going to duplicate most of the code inside analogRead() anyway if you roll it yourself. That said, I've done plenty of projects with bare avr-gcc (especially for chips not supported by Arduino at the time) and it's not terribly onerous, but often you don't need that level of control for every little thing.
- tmuir 9y agoAs an embedded developer, I would agree that there is this sentiment that arduino is somehow inferior, bigger code sizes, worse code quality, training wheels, etc. However, I've recently used a couple different Teensy boards in some personal projects, which are a line of 3 or 4 different freescale kinetis cortex M0-M4 parts that have their own plugin for the arduino IDE. I've been very impressed with the breadth of libraries, and how well it all works and integrates between different boards. The code is well written, and looks like it could easily be dropped into arm-gcc. Maybe Teensy is the exception, but there are some high quality Arduino codebases out there. Not being able to use in circuit debug tools is a huge pain, however.
- jpindar 9y agoA Pro Mini is 0.8 inch by 1.3 inch. What size do you consider not too bulky?
- HeyLaughingBoy 9y agoI've been programming microcontrollers my entire programming career and now do a fair amount of work with Arduino. The only advantage I've found to not using the Arduino libraries is when I need raw speed. e.g., a few months ago I had a project where I needed to read an analog input, calculate/lookup sine & cosine, do some math, and generate an output all within 300 uS. At first glance, it seems trivial, but there was no way the Arduino libraries were fast enough. They are optimized for ease of use, not speed. However, remember that in most modern programming, the programmer time is the most expensive variable. Using the Arduino libraries keeps that cost in check.
- photojosh 9y agoWe often prototype and evaluate new hardware peripherals via Arduino. Once that's done, it's easy enough to port over to a bare AVR.