ATmega328
[Image:ATMEGA328P-PU.jpg|thumb|right|ATmega328P in 28-pin narrow dual in-line package (DIP-28N)]
Image:ICIC-TQ32-X-K328-01.jpg|thumb|right|ATmega328P in 32-pin thin quad flat pack
[Image:ATMEL MEGA328P AU 1328.jpg|thumb|right|Die of ATmega328P]
The ATmega328 is a single-chip microcontroller created by Atmel in the megaAVR family. It has a modified Harvard architecture 8-bit RISC processor core.
Specifications
The Atmel 8-bit AVR RISC-based microcontroller combines 32 KB ISP flash memory with read-while-write capabilities, 1 KB EEPROM, 2 KB SRAM, 23 general-purpose I/O lines, 32 general-purpose working registers, 3 flexible timer/counters with compare modes, internal and external interrupts, serial programmable USART, a byte-oriented 2-wire serial interface, SPI serial port, 6-channel 10-bit A/D converter, programmable watchdog timer with internal oscillator, and 5 software-selectable power-saving modes. The device operates between 1.8 and 5.5 volts.The device achieves throughput approaching 1 MIPS/MHz.
Family
A common alternative to the ATmega328 is the "picoPower" ATmega328P. A comprehensive list of all other members of the megaAVR series can be found on the Atmel website.- ATmega328
- ATmega328P and ATmega328P-AUTOMOTIVE
- ATmega328PB and ATmega328PB-AUTOMOTIVE - has more UART, I2C, and SPI peripherals than ATmega328P
Applications
ATmega328 is commonly used in many projects and autonomous systems where a simple, low-powered, low-cost micro-controller is needed.Perhaps the most common implementation of this chip is on the popular Arduino development platform, namely the Arduino Uno, Arduino Pro Mini and Arduino Nano models.
Programming
Image:ATmega328P 28-PDIP fixed.svg|thumb|upright=1.4|Pinout of ATmega 48A/PA/88A/PA/168A/PA/328/P in 28-PDIPReliability qualification shows that the projected data retention failure rate is much less than over 20 years at 85 °C or 100 years at 25 °C.
| Programming signal | Pin Name | I/O | Function |
| RDY/BSY | PD1 | O | High means the MCU is ready for a new command, otherwise busy. |
| OE | PD2 | I | Output enable |
| WR | PD3 | I | Write pulse |
| BS1 | PD4 | I | Byte select 1 |
| XA0 | PD5 | I | XTAL action bit 0 |
| XA1 | PD6 | I | XTAL action bit 1 |
| PAGEL | PD7 | I | Program memory and EEPROM data page load |
| BS2 | PC2 | I | Byte select 2 |
| DATA | PC:PB | I/O | Bi-directional data bus |
Programming mode is entered when PAGEL, XA1, XA0, BS1 is set to zero. RESET pin to 0 V and VCC to 0 V. VCC is set to 4.5–5.5 V. Wait 60 μs, and RESET is set to 11.5–12.5 V. Wait more than 310 μs. Set XA1:XA0:BS1:DATA =, pulse XTAL1 for at least 150 ns, pulse WR to zero. This starts the chip erase. Wait until RDY/BSY goes high. XA1:XA0:BS1:DATA =, XTAL1 pulse, pulse WR to zero. This is the flash write command. And so on.
| Symbol | Pins | I/O | Description |
| MOSI | PB3 | I | Serial data in |
| MISO | PB4 | O | Serial Data out |
| SCK | PB5 | I | Serial Clock |
Serial data to the MCU is clocked on the rising edge and data from the MCU is clocked on the falling edge. Power is applied to VCC while RESET and SCK are set to zero. Wait for at least 20 ms and then the programming enable serial instruction 0xAC, 0x53, 0x00, 0x00 is sent to the MOSI pin. The second byte will be echoed back by the MCU.