datasheet
Wait! It's not that scary!
The
datasheet for the ATtiny25/45/85 is a godsend.
Its 234 pages are quite daunting at first. There are a few things we can do to make it easier to find the things we're looking for. I've found it especially useful to print out physical copies of pages:
- page 2, the pinout of the chip)
- page 66 for digital I/O
and...
- pages 138-142 for the ADC.
Additionally, unless you are
very familiar with C, I would also recommend printing out a
reference card.
the sidebar
The very first thing that must be done upon downloading the datasheet is to open up the side-bar of your PDF viewer. This will vary depending on your PDF viewer.
In Ubuntu, I use
evince. In Evince, either press F9 or click 'view' then side bar on the topmost menu.
Now, with a side bar open we can begin to explore the different topics with less guess-and-check.
list of abbreviations
List of Abbreviations
Much of the datasheet just
assumes you've read everything before it and
assumes that the reader can figure out what the many, many acronyms expand to. This .txt file has proved to be incredibly useful. Each acronym often is made up of sub-acronyms so it's sometimes a little tricky to get to the bottom of what a given thing stands for--
unless you have this file.
I'd recommend that as you look at the datasheet, you have this file open in another tab or your
favorite text editor. Using your text editor's find function (ctrl-f, '/
' etc.) will be helpful.
(immediately) useful sections
- 10.2: Ports as general I/O
- This section explains how to set pins as inputs and outputs, reading inputs. The only sections that really matter at this point are sections 10.2.1 through 10.2.4, 'configuring the pin', 'toggling the pin', 'switching between input and output' and 'reading the pin value'
- 10.4: Register descriptions
sections that will be useful later
- 17 Analog to Digital Converter:
- 17.4, Starting a Conversion:
- This section explains how to start an analog to digital conversion. It's super confusing the first time around.
- I've taken the liberty of breaking out ADC conversions into a function.
- 17.5, Prescaling and Conversion Timing
- 17.6, Changing channel or Reference selection
- Explains how to change what input will be read by the ADC.
- 17.11.1 Single Ended Conversion:
- is the only one of the three choices we care about. A single ended conversion returns a number from 1 to 1023. I haven't found the need to use the other types of conversions.
- 17.13 Register Description:
- This whole section is highly relevant to understanding how the chip's ADC works.
Up next...
The next section will cover what registers are and how they work.