Explore ATtiny Microcontrollers using C and Assembly Language
1.1 ATtiny Microcontrollers Before we start programming, it is best to get a general understanding of what exactly we will be programming. Various ATtiny devices are listed under the sub-headings that follow. Each sub-heading lists ATtiny devices by number of pins. These sections are followed by a table of all of the devices discussed, to help assimilate the information. All devices listed are available as Dual-Inline Package (DIP) chips. In the Microchip/Atmel documentation for ATtiny devices, DIP ICs are known as Plastic Dual-Inline Package, or PDIP devices. Although the text uses 8-pin ATtiny devices, it is possible to use devices that have more pins. Devices with more pins are discussed for readers who may be interested in them. The motivation for specifying DIP or PDIP ATtiny microcontrollers is that they are much easier to use on an electronic breadboard, and programming is supported by many different USB programming devices via the ISP/SPI programming interface. ATtiny surface mount device (SMD) parts can also be used with a breadboard, but need to be mounted on a breakout board, or similar printed circuit board (PCB). Each PDIP device is also available in a surface mount package, so using a breakout board with an SMD equivalent of a DIP ATtiny is fine too. Basic pinout diagrams of various ATtiny microcontrollers are shown in the figures in each subsection that follows. ATtiny and ATmega microcontrollers all have one or more internal 8-bit ports that are attached to the pins of each microcontroller, one port bit per pin. These ports are named Port A, Port B, Port C and so on, or with a shorter notation PA, PB, PC, etc. Ports allow microcontroller pins to be configured and manipulated in software. On devices that have few pins, only a certain number of port bits are available on the pins of the devices, and not the full 8-bits of a port. When looking at the figures that follow, notice that the pins for a port are labeled with the shorter notation. For example, pins labeled PB0, PB1, PB2, etc. are pins from port B or PB of the microcontroller. These pins are input/output (I/O) pins that can be individually configured as either inputs or outputs in software. Port pins are also multiplexed with various internal peripherals, such as analog to digital converters (ADCs), or timer outputs. This means that a pin can be configured as either an input, or an output, or as a special function pin connected to an internal peripheral. The actual function of the pin is configurable in software. In the figures that follow, only the basic port pin numbers are shown, and not the alternate functionality. 32