View detail for Atmel AVR541: Migrating from AT90PWM81 to AT90PWM161

APPLICATION NOTE
Atmel AVR541: Migrating from AT90PWM81 to
AT90PWM161
8-bit Atmel Microcontrollers
Features
•
•
•
•
•
•
General porting consideration
Flash memory
SRAM
Signature row
Interrupt vectors
CALL instructions
Introduction
This application note aims to outline the differences between Atmel® AT90PWM81
and Atmel AT90PWM161. For detailed information on the devices, refer to the
datasheets.
The AT90PWM81 and AT90PWM161 are designed to be a pin- and functioncompatible family, and have the same datasheet. The memory sizes are the main
difference between AT90PWM81 and AT90PWM161. Because of the differences
mentioned in this document, there might be a need for some minor modifications in
the application when porting code between the devices.
Minor differences in typical characteristics are not discussed in this document as long
as the low and high limits remain the same. For detailed information about the typical
characteristics, see sections “Electrical Characteristics” and “Typical Characteristics”
of the device datasheet.
Note:
This application note serves as a guide to ease migration. For complete
device details, always refer to the most recent version of
the AT90PWM81/161 datasheet.
8346B−AVR−08/2012
1.
Flash
The flash memory sizes are different between Atmel AT90PWM81 (8kB) and Atmel AT90PWM161 (16kB). The flash
memory is accessed in groups by pages that are of different sizes also. The differences are listed in Table 1-1.
Table 1-1.
1.1
Memory sizes.
FLASH [bytes]
FLASH page size [words]
Number of pages
AT90PWM81
8192
32
128
AT90PWM161
16384
64
128
Application flash section
The application flash section size varies according to the device configuration. All options are summarized in Table 1-2.
Table 1-2.
1.2
Application flash section address.
BOOTSZ: 11 [words]
BOOTSZ: 10 [words]
BOOTSZ: 01 [words]
BOOTSZ: 00 [words]
AT90PWM81
0x000-0xF7F
0x000-0xEFF
0x000-0xDFF
0x000-0xBFF
AT90PWM161
0x000-0x1EFF
0x000-0x1DFF
0x000-0x1BFF
0x000-0x17FF
Boot loader flash section
The various boot loader flash section sizes vary according to the device configuration. All options are summarized
in Table 1-3. The addresses are summarized in Table 1-4.
Table 1-3.
BOOTSZ: 11 [words]
BOOTSZ: 10 [words]
BOOTSZ: 01 [words]
BOOTSZ: 00 [words]
AT90PWM81
128
256
512
1024
AT90PWM161
256
512
1024
2048
BOOTSZ: 11 [words]
BOOTSZ: 10 [words]
BOOTSZ: 01 [words]
BOOTSZ: 00 [words]
AT90PWM81
0xF80-0xFFF
0xF00-0xFFF
0xE00-0xFFF
0xC00-0xFFF
AT90PWM161
0x1F00-0x1FFF
0x1E00-0x1FFF
0x1C00-0x1FFF
0x1800-0x1FFF
Table 1-4.
2.
Bootloader flash section sizes.
Bootloader flash section address.
SRAM
The SRAM size differences between AT90PWM81 and AT90PWM161 are listed in Table 2-1.
Table 2-1.
SRAM sizes.
SRAM [bytes]
AT90PWM81
256
AT90PWM161
1024
Atmel AVR541: Migrating from AT90PWM81 to AT90PWM161 [APPLICATION NOTE]
8346B−AVR−08/2012
2
3.
Signature row
The Device ID differences between Atmel AT90PWM81 and Atmel AT90PWM161 are detailed in Table 3-1:
Table 3-1.
4.
Device ID differences.
Signature Byte
Address
AT90PWM81 Data
AT90PWM161 Data
Device ID 1, Flash size
0x02
93H
94H
Device ID 2, Device
0x04
88H
8BH
Interrupt vector table
The Interrupt vector addresses are different between the AT90PWM81 and AT90PWM161. Interrupt addresses of
AT90PWM861 have an increment equal to one word, whereas interrupt addresses of AT90PWM161 have an increment
equal to two words (see Table 4-1).
Table 4-1.
Reset and interrupt vectors.
Vector no.
AT90PWM81
program address
AT90PWM161
program address
Source
Interrupt definition
1
0x0000
0x0000
RESET
External Pin, Power-on Reset, Brown-out Reset,
Watchdog Reset, and Emulation AVR® Reset
2
0x0001
0x0002
PSC2 CAPT
PSC2 Capture Event
3
0x0002
0x0004
PSC2 EC
PSC2 End Cycle
4
0x0003
0x0006
PSC2 EEC
PSC2 End of Enhanced Cycle
5
0x0004
0x0008
PSCr CAPT
PSC reduced Capture Event
6
0x0005
0x000A
PSCr EC
PSC reduced End Cycle
7
0x0006
0x000C
PSCr EEC
PSC reduced End of Enhanced Cycle
8
0x0007
0x000E
ANACOMP 0
Analog Comparator 0
9
0x0008
0x0010
ANACOMP 1
Analog Comparator 1
10
0x0009
0x0012
ANACOMP 2
Analog Comparator 2
11
0x000A
0x0014
INT0
External Interrupt Request 0
12
0x000B
0x0016
TIMER1 CAPT
Timer/Counter1 Capture Event
13
0x000C
0x0018
TIMER1 OVF
Timer/Counter1 Overflow
14
0x000D
0x001A
ADC
ADC Conversion Complete
15
0x000E
0x001C
INT1
External Interrupt Request 1
16
0x000F
0x001E
SPI, STC
SPI Serial Transfer Complete
17
0x0010
0x0020
INT2
External Interrupt Request 2
18
0x0011
0x0022
WDT
Watchdog Time-Out Interrupt
19
0x0012
0x0024
EE READY
EEPROM Ready
20
0x0013
0x0026
SPM READY
Store Program Memory Ready
Atmel AVR541: Migrating from AT90PWM81 to AT90PWM161 [APPLICATION NOTE]
8346B−AVR−08/2012
3
5.
CALL instruction
For Atmel AT90PWM81, the RCALL instruction can match the entire address space, but for Atmel AT90PWM161,
which has more than 8Kbytes, the CALL instruction is used by the compiler.
The CALL instruction takes one cycle more than the RCALL instruction, and real-time execution would be impacted.
The ICALL instruction takes the same number of cycles as RCALL, but is dedicated by the compiler to call functions
through a function pointer.
To reduce the number of CALL instructions, one can configure AVR Studio® as follows:
Project->options->C/C++ Compiler->Optimizations-> check the option "Multi-file Compilation," and also check the option
"Speed."
Then, if all the files are compiled at the same time, the Compiler should be able to optimize the use of RCALL/CALL.
6.
Datasheet changes
For a summary of changes, see the revision history at the end of the AT90PWM81/161 datasheet.
Atmel AVR541: Migrating from AT90PWM81 to AT90PWM161 [APPLICATION NOTE]
8346B−AVR−08/2012
4
Atmel Corporation
Atmel Asia Limited
Atmel Munich GmbH
Atmel Japan G.K.
1600 Technology Drive
Unit 01-5 & 16, 19F
Business Campus
16F Shin-Osaki Kangyo Bldg.
San Jose, CA 95110
BEA Tower, Millennium City 5
Parkring 4
1-6-4 Osaki, Shinagawa-ku
USA
418 Kwun Tong Road
D-85748 Garching b. Munich
Tokyo 141-0032
Tel: (+1)(408) 441-0311
Kwun Tong, Kowloon
GERMANY
JAPAN
Fax: (+1)(408) 487-2600
HONG KONG
Tel: (+49) 89-31970-0
Tel: (+81)(3) 6417-0300
www.atmel.com
Tel: (+852) 2245-6100
Fax: (+49) 89-3194621
Fax: (+81)(3) 6417-0370
Fax: (+852) 2722-1369
© 2012 Atmel Corporation. All rights reserved. / Rev.: Datasheet−TEMPLATE−06/12
Atmel®, Atmel logo and combinations thereof, AVR®, AVR Studio®, Enabling Unlimited Possibilities®, and others are registered trademarks or trademarks of Atmel
Corporation or its subsidiaries. Other terms and product names may be trademarks of others.
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 THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, 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 AND 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 products 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 products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.