AVR506: Migration from ATmega169 to ATmega169P

AVR506: Migration from ATmega169 to
ATmega169P
Features
•
•
•
•
•
General Porting Considerations
Register and bit names
Memory
Clock sources
IO pins
8-bit
Microcontrollers
Application Note
1 Introduction
This application note summarizes the relevant differences when migrating from
ATmega169 to ATmega169P. For detailed information on the devices please see
the respective datasheets.
The ATmega169P is designed to be pin and functionality compatible with
ATmega169, but because of improvements mentioned in this application note there
may be a need for minor modifications in the application when migrating from
ATmega169 to ATmega169P.
Rev. 8028C-AVR-02/07
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 ATmega169 and ATmega169P some register bits has been added, but
none of the existing bits has been removed, nor moved to different locations.
In ATmega169 the USART module is named USART, while in ATmega169P it is
called USART0. This has consequences for all USART register and bit names, and
depending on the compiler used this might have consequences when porting the
code. Table 3-1 shows the register names for ATmega169.
Table 3-1. USART register names
ATmega169
Register name
UDR
UCSRA
UCSRB
2
Atmega169
Bit names
RXB[7:0]
TXB[7:0]
ATmega169P
Register name
UDR0
ATmega169P
Bit names
RXB0[7:0]
TXB0[7:0]
RXC
RXC0
TXC
TXC0
UDRE
UDRE0
FE
DOR
UCSR0A
FE0
DOR0
UPE
UPE0
U2X
U2X0
MPCM
MPCM0
RXCIE
UCSR0B
RXCIE0
TXCIE
TXCIE0
UDRIEN
UDRIEN0
RXEN
RXEN0
TXEN
TXEN0
UCSZ2
UCSZ02
RXB8
RXB80
AVR506
8028C-AVR-02/07
AVR506
TXB8
TXB80
-
-
UMSEL
UMSEL0
UPM1
UPM01
UPM0
UCSRC
USBS
UPM00
UCSR0C
USBS0
UCSZ1
UCSZ01
UCSZ0
UCSZ00
UCPOL
UCPOL0
UBRRH
UBRR[11:8]
UBRR0H
UBRR0[11:8]
UBRRL
UBRR[7:0]
UBRR0L
UBRR0[7:0]
4 Memory
The EEPROM write times are different, and can be seen Table 4-1
Table 4-1. Wait times when programming EEPROM
Device
Typical programming time
ATmega169
8.5 ms
ATmega169P
3.3 ms
5 Clock sources
The clock sources for ATmega169P have different characteristics from ATmega169
and might have to be taken into account. The differences are described in the
following subsections.
5.1 Internal RC oscillator
The internal RC oscillator in ATmega169P is based on a different design than the
ATmega169. The OSCCAL register is 8-bit instead of 7-bit, where the high bit selects
one of two overlapping frequency ranges. Refer to the datasheets for information on
calibration of the oscillators.
5.2 Low-frequency Crystal / Timer/Counter Oscillator
The low frequency / Timer/counter crystal oscillator of the ATmega169P is optimized
for very low power consumption and thus the crystal driver strength is reduced
compared to the ATmega169. 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. Table 5-1 shows the
ESR recommendations for ATmega169P. The internal capacitance of ATmega169P
low-frequency oscillator is typically 6pF, but the tracks to the crystal will add some
additional capacitance.
3
8028C-AVR-02/07
Table 5-1. ESR and load capacitance recommendation for 32.768 kHz crystals.
Note:
Crystal CL [pF]
Max ESR1 [kΩ]
6.5
60
9
35
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 75 and 45 kΩ respectively.
For examples of crystals that comply with the requirements see Appendix A.
The startup times are also increased as shown in Table 5-2.
Table 5-2. Startup times with 32.768 kHz crystals.
Crystal CL [pF]
Startup time2 [ms]
ATmega169
Startup time2 [ms]
Atmega169P
6.5
-
800
9
300
1200
12.5
400
-
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.
6 IO pins
ATmega169P have an option to disable the external reset feature. The /RESET pin
then becomes an input only IO pin. The reset disable feature is not available on
ATmega169.
7 Appendix A
Table 7-1 is a selection of crystals that
ATmega169P. The crystals are listed based
tested with the ATmega169P. Any other
requirements can also be used. Availability
investigated.
meet the ESR requirements of the
on datasheet information and are not
crystal that complies with the ESR
and RoHS compliance has not been
Table 7-1. Examples of crystals compliant with ATmega169P Low-frequency Crystal Oscillator requirements.
Vendor
Type
Mounting
(SMD/HOLE)
Frequency Tolerance
[±ppm]
Load
Capacitance [pF]
Equivalent Series
Resistance (ESR)
[kΩ]
C-MAC
WATCH CRYSTALS
HOLE
20
6
50
C-MAC
85SMX
SMD
20
6
55
C-MAC
90SMX
SMD
20
6
60
ECLIPTEK
E4WC
HOLE
20
6
50
ENDRICH
90SMX
SMD
5
6
50
EPSON
C-001R
HOLE
20
6
35
4
AVR506
8028C-AVR-02/07
AVR506
Vendor
Type
Mounting
(SMD/HOLE)
Frequency Tolerance
[±ppm]
Load
Capacitance [pF]
Equivalent Series
Resistance (ESR)
[kΩ]
EPSON
C-002RX
HOLE
20
6
50
EPSON
C-004R
HOLE
20
6
50
EPSON
C-005R
HOLE
20
6
50
EPSON
MC-30A
SMD
20
6
50
EPSON
MC-306
SMD
20
6
50
EPSON
MC-405
SMD
20
6
50
EPSON
MC-406
SMD
20
6
50
GOLLEDGE
GWX
HOLE
5
6
35
GOLLEDGE
GSWX-26
SMD
10
6
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
MICROCRYSTAL
MS2V-T1R
HOLE
20
7
65
MICROCRYSTAL
MS3V-T1R
HOLE
20
7
65
MMD
WC26
HOLE
8
6
35
MMD
WCSMC
SMD
20
6
50
OSCILENT
SERIES 111
HOLE
10
6
30
OSCILENT
SERIES 112
HOLE
10
6
40
OSCILENT
SERIES 223
SMD
20
6
50
RALTRON
SERIES R38
HOLE
5
6
35
RALTRON
SERIES R26
HOLE
5
6
35
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
40
SUNTSU
SCT2
HOLE
20
6
50
SUNTSU
SCT3
HOLE
20
6
50
SUNTSU
SCP1
SMD
20
6
50
SUNTSU
SCT2G
SMD
20
6
50
5
8028C-AVR-02/07
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.
© 2007 Atmel Corporation. All rights reserved. ATMEL®, logo and combinations thereof, Everywhere You Are®, AVR®, and others are the
registered trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.
8028C-AVR-02/07