ATmega32U2 Atmel Corporation, ATmega32U2 Datasheet
![no-image](/images/manufacturer_photos/0/0/79/atmel_corporation_sml.jpg)
ATmega32U2
Specifications of ATmega32U2
Available stocks
Related parts for ATmega32U2
ATmega32U2 Summary of contents
Page 1
Features • USB Protocol – Based on the USB DFU class – Autobaud (8/16 MHz crystal) • In-System Programming – Read/Write Flash and EEPROM on-chip memories – Read Device ID – Full chip Erase – Start application command • In-Application ...
Page 2
Bootloader Environment The bootloader is located in the boot section of the on-chip Flash memory, it manages the USB communication protocol and performs read/write operations to the on-chip memories (Flash/EEPROM). The USB bootloader is loaded in the “Bootloader Flash ...
Page 3
Boot Reset Fuse The Boot Reset Fuse (BOOTRST) can be programmed so that the Reset Vector points to the Boot Flash section start address after reset. Once the user code is loaded, a bootloader command (“start application”) can start ...
Page 4
DFU is not capable of changing its mode of operation on its own. External (human or host operating system) intervention is required. 4.2 DFU Specific Requests In addition to the USB standard requests, 7 DFU class-specific requests ...
Page 5
Offset Field 15 iProduct 16 iSerialNumber 17 bNumConfigurations 4.3.2 DFU Configuration Descriptor This descriptor is identical to the standard configuration descriptor described in the USB DFU specification version 1.0, with the exception that the bNumInterfaces field must contain the value ...
Page 6
Device Status 4.5.1 Get Status The Host employs the DFU_GETSTATUS request to facilitate synchronization with the device. This status gives information on the execution of the previous request: in progress/OK/Fail/... bmRequestType 1010 0001b 0010 0001b The device responds to ...
Page 7
Status errVENDOR errUSBR errPOR errUNKNOWN errSTALLEDPK Table 4-6. State appIDLE appDETACH dfuIDLE dfuDNLOAD-SYNC dfuDNBUSY dfuDNLOAD-IDLE dfuMANIFEST-SYNC dfuMANIFEST dfuMANIFEST-WAIT- RESET dfuUPLOAD-IDLE dfuERROR 4.5.2 Clear Status Each time the device detects and reports an error indication status to the host in response ...
Page 8
Device State The state reported is the current state of the device up to transmission of the response. The val- ues specified in the bState field are identical to those reported in DFU_GETSTATUS. bmRequestType 1010 0001b 4.5.4 DFU_ABORT request ...
Page 9
Offset -10 -12 -14 4.6.1 Request From Host bmRequestType 0010 0001b 4.6.1.1 Write Command Command Identifier data[0] 00h Id_prog_start 01h 01h The write command is 6 bytes long. In order to meet with the USB specification of the Control type ...
Page 10
Figure 4-1. SETUP OUT OUT OUT OUT IN The Host sends a DFU_DNLOAD request with Zero Length Packet (ZLP) to indicate that it has completed transferring the firmware image file. This is the final payload packet of a download operation. ...
Page 11
First Request from Host The Host sends a DFU Download request with a Display command in the data field. Command Identifier Id_display_data 4.7.2 Second Request from Host The Host sends a DFU Upload request. 4.7.3 Answers from the Device ...
Page 12
Answers from the Device to a Blank Check Command The Host controller sends a GET_STATUS request to the device. Once internal blank check has been completed, the device sends its status. • If the device status is “OK”: the ...
Page 13
Erasing the Flash The flow described below allows the user to erase the Flash memory. The Full Chip erase command erases the whole Flash. 4.9.1 Request from Host To start the erasing operation, the Host sends a DFU_DNLOAD request ...
Page 14
Important note: The bootloader performs a watchdog reset to generate the “hardware reset” that allows to exe- cute the application section. After a watchdog reset occurs, the AVR watchdog is still running, thus the application should take care to disable ...
Page 15
Accessing the Low level Flash Drivers The AT90USB USB bootloader is located in the boot section of the on-chip flash memory, mean- while the bootloader section is the unique memory location allowed to execute on-chip flash memory write operations ...
Page 16
The API are located at absolute addresses in the USB bootloader firmware and accept specific registers values as parameters. These parameters are compatible with a C compiler calling con- vention and thus can be called directly with function pointer declared ...
Page 17
Using the USB bootloader for In System Programming Flip software is the PC side application used to communicate with the USB bootloader (Flip is available for free on the Atmel website). For detailed instructions about using Flip and USB ...
Page 18
Bootloader History The following table shows the different bootloader revision and associated changes. Table 8-1. Product AT90USB1287 AT90USB1286 AT90USB647 AT90USB646 AT90USB162 AT90USB82 ATmega32U4 ATmega16U4 9. Appendix-A Table 9-1. Command Identifier Id_prog_start 01h Id_display_data 03h Id_write_command 04h Id_read_command 05h Id_change ...
Page 19
Table 9-2. bmRequestType 0010 0001b 0010 0001b 1010 0001b 1010 0001b 0010 0001b 1010 0001b 0010 0001b 7618C–AVR–07/08 DFU Class-specific Requests bRequest wValue DFU_DETACH (0) wTimeout DFU_DNLOAD (1) wBlock DFU_UPLOAD (2) wBlock DFU_GETSTATUS (3) Zero DFU_CLRSTATUS (4) Zero DFU_GETSTATE (5) ...
Page 20
Appendix-B ;*A************************************************************************ ** ; $RCSfile: flash_boot_drv.s90,v $ ;-------------------------------------------------------------------------- -- ; Copyright (c) Atmel. ;-------------------------------------------------------------------------- -- ; RELEASE: ; REVISION: ; FILE_CVSID: ;-------------------------------------------------------------------------- -- ; PURPOSE: ; This file contains the low level driver for the flash access ;************************************************************************** ** ...
Page 21
RSEGBOOT ;*F************************************************************************ ** ; NAME: flash_page_erase_and_write ;-------------------------------------------------------------------------- -- ; PARAMS: ;-------------------------------------------------------------------------- -- ; PURPOSE: This function can be called for the user appplication ; This function performs an erase operation of the selected target ...
Page 22
RCALL MOV MOV OUT LDI OUT SPMCSR,R20; argument 2 decides function (r18) SPM RCALL RCALL RET ;*F************************************************************************ ** ; NAME: flash_page_erase ;-------------------------------------------------------------------------- -- ; PARAMS: ;-------------------------------------------------------------------------- -- ; PURPOSE: ;-------------------------------------------------------------------------- -- ; NOTE: not ; erase the ...
Page 23
NAME: flash_page_erase_public ;-------------------------------------------------------------------------- -- ; PARAMS: ;-------------------------------------------------------------------------- -- ; PURPOSE: ;-------------------------------------------------------------------------- -- ; NOTE: ; erase the hardware temporary temp buffer after page erase ;************************************************************************** ** flash_page_erase_public: RCALL MOV MOV OUT LDI OUTSPMCSR, R20; argument 2 decides ...
Page 24
NAME: flash_read_sig ;-------------------------------------------------------------------------- -- ; PARAMS: ; Return: R16: signature value ;-------------------------------------------------------------------------- -- ; PURPOSE: addr ; passed as argument (see product data sheet) ;************************************************************************** ** flash_read_sig: RCALL MOV MOV OUT LDI OUT SPMCSR, R20; argument 2 ...
Page 25
RJMP /*F************************************************************************ ** * NAME: flash_fill_temp_buffer *-------------------------------------------------------------------------- -- * PARAMS: * data16 : * address: * return: *-------------------------------------------------------------------------- -- * PURPOSE: * This function allows to load a word in the temporary flash buffer. *-------------------------------------------------------------------------- -- * EXAMPLE: * fill_temp_buffer(data16, ...
Page 26
RCALL MOV LDI OUT SPMCSR, R18 ; r18 decides function SPM RJMP ;*F************************************************************************ ** ; NAME: wait_spmen ;-------------------------------------------------------------------------- -- ; PARAMS: ;-------------------------------------------------------------------------- -- ; PURPOSE: ;************************************************************************** ** WAIT_SPMEN: MOVR0, R18 INR18, SPMCSR SBRC RJMP MOVR18, R0 RET END 26 WAIT_SPMEN ...
Page 27
Document Revision History 11.1 7618B 03/08 1. Removed references to DFU Functional Descriptor throughout the document. 11.2 7618C 07/08 1. Update for AT90USB162/82, AT90USB64x, ATmega32U4 and ATmega16U4. 2. Update bootloader revision history. 7618C–AVR–07/08 27 ...
Page 28
... Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel’s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. © 2008 Atmel Corporation. All rights reserved. Atmel Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. International Atmel Asia ...