Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • Note that this code should also work with Atmega32u4 (used in Leonardo) as it contains more timers than ATmega328P. Commented Feb 24, 2014 at 5:52
  • 1
    @Ricardo - Probably 90%+ of small-MCU embedded code uses direct register manipulation. Doing things with indirect utility functions is very much not the common mode of manipulating IO/peripherals. There are some toolkits for abstracting away hardware control (The Atmel ASF, for example), but that's generally written to compile away as much as possible to reduce runtime overhead, and almost invariably requires actually understanding the peripherals by reading the datasheets. Commented Feb 24, 2014 at 17:26
  • 1
    Basically, arduino stuff, by saying "here are functions that do X", without really bothering to reference the actual documentation or how the hardware is doing the things it does, is very much not normal. I understand it's value as a introductory tool, but except for quick prototyping, it's not really ever done in actual professional environments. Commented Feb 24, 2014 at 17:27
  • 1
    To be clear, the thing that makes arduino code unusual for embedded MCU firmware is not unique to arduino code, it's a function of the overall approach. Basically, once you have a decent understanding of the actual MCU, doing things properly (e.g. using hardware registers directly) takes little to no additional time. As such, if you want to learn real MCU dev, it's much better to just sit down and understand what your MCU is actually doing, rather then relying on someone else's abstraction, which tends to be leaky. Commented Feb 24, 2014 at 17:30
  • 1
    Note that I may be a bit cynical here, but a lot the behaviours I see in the arduino community are programming anti-patterns. I see a lot of "copy-paste" programming, the treating of libraries as black-boxes, and just general poor design practices in the community at large. Of course, I'm fairly active on EE.stackexchange, so I may have a somewhat slanted view, since I have some moderator tools, and as such see a lot of the closed questions. There is definitely a bias in the arduino questions I've seen there towards "tell me what to C&P to fix", rather then "why is this not working". Commented Feb 24, 2014 at 17:39