1
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 :<any branch or jump instruction to Wait_Label>
<any two word instruction>
•For C programs (using IAR C Compiler V1.0 and later):
for(;;)
;
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 :<any branch or jump instruction to Wait_Label>
nop
<any two word instruction>
•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.
Embedded RISC
Microcontroller
Core V2
Errata Sheet
Rev. 1383A–06/00