Downloading Code
The AVR processors use internal flash memory for program storage, and this may be programmed in-circuit or, in the case of socketed components, out of circuit as well. The AVR processors are reprogrammed via a SPI (Serial Peripheral Interface) port on the chip. (SPI is explained in detail in Chapter 9.) Even AVR processors such as the ATtiny15, which do not have a SPI interface for their own use, still incorporate a SPI port for reprogramming. The pins PB0, PB1, and PB2 take on SPI functions (MOSI, MISO, and SCK) during programming.
VCC can be supplied by the external programmer downloading the code. For programming, VCC must be 5V. If the embedded system’s local supply will provide 5V, then the connection to the programmer’s VCC may be left unmade. However, if the embedded system’s supply voltage is something other than 5V, the programmer’s VCC must be used, and any local power source within the embedded system should be disabled. RESET plays an important role. Programming begins with RESET being asserted (driven low). This disables the CPU within the processor and thus allows access to the internal memory. It also changes the functionality of PB0, PB1, and PB2 to a SPI interface. The development software then sends, via the SPI interface, a sequence of codes to “unlock” the program memory and enable software to be downloaded. Once programming is enabled, sequences of write commands are performed, and the software (and other settings) are downloaded byte ...
Get Designing Embedded Hardware now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.