AVR512: Migration from ATmega48/88/168 to ATmega48P/88P/168P Features • General Porting Considerations • Register and bit names • Low-frequency Crystal / Timer/Counter Oscillator 8-bit Microcontrollers Application Note 1 Introduction This application note summarizes the relevant differences when migrating from ATmega48/88/168 to ATmega48P/88P/168P. For detailed information on the devices please see the respective datasheets. The ATmega48P/88P/168P is designed to be pin and functionality compatible with ATmega48/88/168, but because of improvements mentioned in this application note there may be a need for minor modifications in the application when migrating from ATmega48/88/168 to ATmega48P/88P/168P. For details on migrating between ATmega48P/88P/168P refer to the migration note AVR®095: Migrating between ATmega48, ATmega88 and ATmega168. Rev. 8035A-AVR-07/06 2 General Porting Considerations To make the porting process as easy as possible, we recommend to always refer to registers and bit positions using their defined names, as absolute addresses and values may change from device to device. When porting a design it is then often just necessary to include the correct definition file. Some examples are shown below. PORTE |= (1<<PORTE5); DDR &= ~(1<<PORTE5); // Set pin 5 on port E high // Set pin 5 on port E as input // Configure USI USICR = (1<<USISIE)|(0<<USIOIE)|(1<<USIWM1)|(0<<USIWM0)| (1<<USICS1)|(0<<USICS0)|(0<<USICLK)|(0<<USITC); To avoid conflicts with added features and register functionality, never access registers that are marked as reserved. Reserved bits should always be written to zero if accessed. This ensures forward compatibility, and added features will stay in their default states when unused. 3 Register and bit names Between ATmega48/88/168 and ATmega48P/88P/168P some register bits has been added, but none of the existing bits has been removed, nor moved to different locations. 4 Low-frequency Crystal / Timer/Counter Oscillator The low frequency crystal oscillator of the ATmega48P/88P/168P is optimized for very low power consumption thus the crystal driver strength is reduced compared to the ATmega48/88/168. This means that when selecting a crystal, its load capacitance and Equivalent Series Resistance (ESR) must be taken into consideration. Both values are specified by the crystal vendor. The internal capacitance of ATmega164P/324P/644P low-frequency oscillator is typically 6pF, but the tracks to the crystal will add some additional capacitance. Table 4-1 shows the ESR recommendations for ATmega48P/88P/168P. Table 4-1. ESR recommendation for 32.768 kHz crystals for ATmega48P/88P/168P. Note: Crystal CL [pF] Max ESR1 [kΩ] 6.5 75 9 65 12.5 30 1. The values stated are for an oscillator allowance safety margin of 5. Since the oscillator’s transconductance is temperature compensated one can use a safety margin of 4, thus giving a max ESR of 90, 80 and 40 kΩ respectively. For examples of crystals that comply with the requirements see Appendix A. 2 AVR512 8035A-AVR-07/06 AVR512 The startup times are increased as shown in Table 4-2. Table 4-2. Startup times with 32.768 kHz crystals. Startup time2 [ms] Atmega48/88/168 Startup time2 [ms] Atmega48P/88P/168P 6.5 - 600 9 300 700 12.5 400 1700 Crystal CL [pF] Note: 2. Crystals usually need ~3000ms before they are completely stable with any oscillator design. The time stated is before the crystal is running with a sufficient amplitude and frequency stability. 5 Appendix A Table 5-1 is a selection of crystals that meet the ESR requirements of the ATmega48P/88P/168P. The crystals are listed based on datasheet information and are not tested with the actual device. Any other crystal that complies with the ESR requirements can also be used. Availability and RoHS compliance has not been investigated. Table 5-1. Examples of crystals compliant with ATmega48P/88P/168P low-frequency Crystal Oscillator. Mounting (SMD/HOLE) Frequency Tolerance [±ppm] Load Capacitance [pF] Equivalent Series Resistance (ESR) [kΩ] Vendor Type C-MAC WATCH CRYSTALS HOLE 20 6 50 C-MAC 85SMX SMD 20 6 55 90SMX SMD 20 6 60 ECLIPTEK E4WC HOLE 20 6 50 ENDRICH 90SMX SMD 5 6 50 EPSON C-001R HOLE 20 6 -> 12.5 (specify) 35 EPSON C-002RX HOLE 20 6 -> 10 (specify) 50 EPSON C-004R HOLE 20 6 -> 10 (specify) 50 EPSON C-005R HOLE 20 6 -> 10 (specify) 50 EPSON MC-30A SMD 20 6 -> 10 (specify) 50 EPSON MC-306 SMD 20 6 -> 10 (specify) 50 EPSON MC-405 SMD 20 6 -> 10 (specify) 50 EPSON MC-406 SMD 20 6 -> 10 (specify) 50 GOLLEDGE GWX HOLE 5 6, 8 or 12.5 35 GOLLEDGE GSWX-26 SMD 10 6 , 8 or 12.5 35 GOLLEDGE GDX1 HOLE 10 6 42 GOLLEDGE GSX-200 SMD 5 6 50 IQD WATCH CRYSTALS HOLE 20 6 50 IQD 90SMX HOLE 10 6 60 IQD 91SMX HOLE 10 6 60 C-MAC ® ® 3 8035A-AVR-07/06 Mounting (SMD/HOLE) Frequency Tolerance [±ppm] Load Capacitance [pF] Equivalent Series Resistance (ESR) [kΩ] Vendor Type MICROCRYSTAL MS3V-T1R HOLE 20 7 or 9 65 MICROCRYSTAL MS2V-T1R HOLE 20 7 or 9 65 MICROCRYSTAL CC4V-T1A SMD 30 9 65 MICROCRYSTAL CC1V-T1A SMD 30 9 60 MICROCRYSTAL CC7V-T1A SMD 30 9 70 MMD WC26 HOLE 8 8 35 MMD WC38 HOLE 8 8 35 MMD WC155 HOLE 8 8 40 MMD WCSMC SMD 20 6 50 OSCILENT SERIES 111 HOLE 10 6 or 12.5 30 OSCILENT SERIES 112 HOLE 10 6 or 12.5 40 OSCILENT SERIES 113 HOLE 10 8 40 OSCILENT SERIES 223 SMD 20 6 50 RALTRON SERIES R38 HOLE 5 6 or 12.5 35 RALTRON SERIES R26 HOLE 5 6 or 12.5 35 RALTRON SERIES R145 HOLE 5 8 40 RALTRON SERIES RSE A, B, C, D SMD 20 6 50 SBTRON SBX-13 SMD 20 6 50 SBTRON SBX-20 SMD 20 6 50 SBTRON SBX-21 SMD 20 6 50 SBTRON SBX-24 SMD 20 6 50 SBTRON SBX-23 SMD 20 6 50 SBTRON SBX-22 SMD 20 6 50 SBTRON SBX-14 HOLE 20 6 50 SUNTSU SCT1 HOLE 20 6, 8, 10 or 12.5 40 SUNTSU SCT2 HOLE 20 6, 8, 10 50 SUNTSU SCT3 HOLE 20 6, 8, 10 50 SUNTSU SCP1 SMD 20 6 50 SUNTSU SCT2G SMD 20 6 or 10 50 ® 4 AVR512 8035A-AVR-07/06 Disclaimer Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 Literature Requests www.atmel.com/literature Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL’S TERMS AND CONDITIONS OF SALE LOCATED ON ATMEL’S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, 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. © 2006 Atmel Corporation. All rights reserved. Atmel®, logo and combinations thereof, Everywhere You Are® and AVR®, are the registered trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. 8035A-AVR-07/06