Loop Back Branch Instructions with Interrupts Errata Sheet Application This errata sheet applies to code in the AVR Core V2 - avr05_cdk1.3.0. Error Description A branch or jump instruction (BRxxx, RJMP, JMP, IJMP) may loop back on itself (-1 length loop). If this loop is followed by a two-word instruction (LDS, STS, JMP, CALL), an interrupt cannot break the loop. In this case, the interrupt vector is never reached and the program loops continuously until the next reset. Bad code examples follow: * For assembler programs: Wait_Label : Embedded RISC Microcontroller Core V2 * For C programs (using IAR C Compiler V1.0 and later): for(;;) Errata Sheet ; Workaround * For assembler programs, avoid -1 length loops followed by a two-word instruction if interrupts are enabled, or replace with the following code: Wait_Label : nop * For C programs (using IAR C Compiler V1.0 and later), avoid the for(;;) instruction or replace with the following code: while(1) ; or do {} while(1); In addition, the user should avoid using the exit instruction in the main { } section. This generates a -1 length loop which cannot be broken later by interrupts if followed by a two-word instruction. Rev. 1383A-06/00 1 Atmel Headquarters Atmel Operations Corporate Headquarters Atmel Colorado Springs 2325 Orchard Parkway San Jose, CA 95131 TEL (408) 441-0311 FAX (408) 487-2600 Europe 1150 E. Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 TEL (719) 576-3300 FAX (719) 540-1759 Atmel Rousset Atmel U.K., Ltd. Coliseum Business Centre Riverside Way Camberley, Surrey GU15 3YL England TEL (44) 1276-686-677 FAX (44) 1276-686-697 Zone Industrielle 13106 Rousset Cedex France TEL (33) 4-4253-6000 FAX (33) 4-4253-6001 Asia Atmel Asia, Ltd. Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimhatsui East Kowloon Hong Kong TEL (852) 2721-9778 FAX (852) 2722-1369 Japan Atmel Japan K.K. 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan TEL (81) 3-3523-3551 FAX (81) 3-3523-7581 Fax-on-Demand North America: 1-(800) 292-8635 International: 1-(408) 441-0732 e-mail literature@atmel.com Web Site http://www.atmel.com BBS 1-(408) 436-4309 (c) Atmel Corporation 2000. Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company's standard warranty which is detailed in Atmel's Terms and Conditions located on the Company's web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel's products are not authorized for use as critical components in life suppor t devices or systems. Marks bearing (R) and/or TM are registered trademarks and trademarks of Atmel Corporation. Terms and product names in this document may be trademarks of others. Printed on recycled paper. 1383A-06/00/xM