Microchip has been the main source for producing PIC and AVR microcontrollers that are mainly used in embedded and industrial automation systems. These modules can perform a number of functions on a tiny chip, preventing you from spending too much and purchasing external components for laying out automation in the relevant project.
In this post, I’ll cover each and everything related to this tiny chip including main features, pinout, pin description, functions, the compiler used and everything you need to know. Let’s get down to the details of this onboard module:
Atmega8 Key Features | ||||
---|---|---|---|---|
No. of Pins | 28 | |||
CPU | 8-Bit AVR | |||
Operating Voltage | 2.7 to 5.5 V | |||
Program Memory | 8K | |||
Program Memory Type | Flash | |||
RAM | 1K Bytes | |||
EEPROM | 512 Bytes | |||
ADC Number of ADC Channels | 10-Bit 6 in PDIP, 8 in TQFP and QFN | |||
Comparator | 1 | |||
PWM Channels | 3 | |||
Oscillator | up to 16 MHz | |||
Timer (3) | 16-Bit Timer (1) 8-Bit Timer (2) | |||
Packages (3) | PDIP (28-Pins) TQFP (32-Pins) QFN (32) | |||
Power Up Timer | Yes | |||
I/O Pins | 23 | |||
Manufacturer | Microchip | |||
SPI | Yes | |||
I2C | Yes | |||
Watchdog Timer | Yes | |||
Brownout Detection (BOD) | Yes | |||
USART | Yes | |||
Sleep Modes | 5 | |||
Minimum Operating Temperature | -55 C | |||
Maximum Operating Temperature | 125 C |
Atmega8 pinout & Description | ||||
---|---|---|---|---|
1 | PC6 RESET PCINT14 | I/O Pin RESET will be generated by keeping this pin LOW for longer than the minimum pulse length Interrupt | ||
2 | PD0 RXD PCINT16 | I/O Pin Serial Receive Pin (USART) Interrupt | ||
3 | PD1 TXD PCINT17 | I/O Pin Serial Transmit Pin (USART)Interrupt | ||
4 | PD2 INT0 PCINT18 | I/O Pin External Interrupt Interrupt | ||
5 | PD3 INT1 OC2B PCINT19 | I/O Pin External Interrupt Dedicated Pin for Timer (PWM Channel) Interrupt | ||
6 | PD4 T0 XCK PCINT20 | I/O Pin T0 ( Timer0 External Counter Input) XCK ( USART External Clock I/O) Interrupt | ||
7 | VCC | Voltage Supply | ||
8 | GND | Ground Pin | ||
9 | PB6 OSC1 XTAL1 PCINT6 | I/O Pin Oscillator Input Pin Interrupt | ||
10 | PB7 OSC2 XTAL2 PCINT7 | I/O Pin Oscillator Output Pin Interrupt | ||
11 | PD5 T1 OC0B PCINT21 | I/O Pin PinT1 ( Timer0 External Counter Input) Dedicated Pin for Timer (PWM Channel) Interrupt | ||
12 | PD6 AIN0 OC0A PCINT22 | I/O PinAnalog Comparator Positive Dedicated Pin for Timer (PWM Channel) Interrupt | ||
13 | PD7 AIN1 PCINT23 | I/O Pin Analog Comparator Negative Interrupt | ||
14 | PB0 ICP1 CLKO PCINT0 | I/O Pin In Circuit Serial Programming Clock Interrupt | ||
15 | PB1 OC1A PCINT1 | I/O Pin Dedicated Pin for Timer (PWM Channel) Interrupt | ||
16 | PB2 SS OC1B PCINT2 | I/O Pin SPI Slave Select Input. When the controller acts as a slave, this pin is LOW Dedicated Pin for Timer (PWM Channel) Interrupt | ||
17 | PB3 MOSI OC2A PCINT3 | I/O Pin MOSI (Master Output Slave Input) for SPI Communication. The data is received by this pin when the controller acts as a slave Dedicated Pin for Timer Interrupt | ||
18 | PB4 MISO PCINT4 | I/O Pin MISO (Master Input Slave Output) for SPI communication. When the controller acts as a slave, the data is sent by a controller to master through this pin Interrupt | ||
19 | PB5 SCK PCINT5 | I/O Pin SCK (SPI Bus Serial Clock). This clock is shared between the controller and other devices for data transfer Interrupt | ||
20 | AVCC | Voltage Supply Pin for ADC | ||
21 | AREF | Voltage Reference | ||
22 | GND | Ground Pin | ||
23 | PC0 ADC0 PCINT8 | I/O Pin Analog Channel 0 Interrupt | ||
24 | PC1 ADC1 PCINT9 | I/O Pin Analog Channel 1 Interrupt | ||
25 | PC2 ADC2 PCINT10 | I/O Pin Analog Channel 2 Interrupt | ||
26 | PC3 ADC3 PCINT11 | I/O Pin Analog Channel 3 Interrupt | ||
27 | PC4 ADC4 SDA PCINT12 | I/O Pin Analog Channel 4 Serial Data (I2C) Interrupt | ||
28 | PC5 ADC5 SCL PCINT13 | I/O Pin Analog Channel 5 Serial Clock (I2C) Interrupt |
Atmega8 incorporates three timers where two are 8-bit and one is a 16-bit timer. These timers can be used both ways i.e. timer as well as a counter where the former is used to create the delay in any running function, controls the internal functions of the controller and increments the instruction cycle, while later is used to count the number of intervals by incrementing the rising and falling edge of the pin and is mainly used for external functions. Apart from these timers, two other timers are included in the device named as
An oscillator start-up timer is used to make the crystal oscillator stable by resetting the controller. And power-up timer generates a minor delay once you power on the device, helping in stabilizing the power in order to generate power signals with continuous intervals.
Five Sleep Modes are incorporated into the device that helps in saving power. These modes include:
The BOD, also known as BOR (Brown Out Reset), is used to resetting the module once the Vcc (voltage supply) goes below a brownout threshold voltage. It is important to note that, the Power Up Timer must be enabled for creating a delay and helping in bringing back the device from a BOD function. In this mode, multiple voltage ranges are created to protect the module once the power drops at the voltage supply line.
ATmega8 comes with a serial peripheral interface (SPI) - A communication module that helps in establishing communication between the microcontroller and other peripheral devices such as shift registers, SD cards, and sensors. It incorporates a separate clock and data lines with the addition of a select line for selecting the relevant device for communication.
Two pins used for SPI communication are as follow:
The MOSI pin receives the data when the controller acts as a slave. And MISO plays a vital role in sending data by the controller while later is put in the slave mode.
The former is a clock signal that synchronizes the data transfer between the devices and is produced by the master device, while the latter is used to carry the required data.
The memory space in the controller is the manifestation of the linear and regular memory map. This AVR module comes with a Harvard Architecture that houses separate memories for both data and program.
The Fast Access File Register comes with 32 x 8 - Bit general purpose working registers that can be accessed with the single clock cycle that assists in performing the ALU (Arithmetic Logic Unit) operation where the result is stored in the Register File.
The I/O Memory can be accessed in multiple ways by direct manner or using data Space locations covering Register File, 0x20 – 0x5F.
The data memory comes with memory space around 1K (1024 bytes). It can be accessed through the five different addressing modes in the AVR architecture named Direct, Indirect, Indirect with Displacement, Indirect with Pre-decrement, and Indirect with Post-increment.
The flexible interrupt module houses control registers that further contain global interrupt enable bit sitting in the Status Register. All these interrupts contain Interrupt Vector Table with Interrupt Vector where the former depends on the Interrupt Vector Position and are inversely proportional to each other.
If you are new to a microcontroller, you may be a little skeptical about the compiler you can use for writing and compiling the code into your AVR controller. I've combined some of the basic compilers where some are better than others in terms of efficiency. Although the free versions may lack some features, they are recommended to start with as a newbie to get hands-on experience with the AVR controller.