[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] patch to fix unbalanced 'cli' that causes interrupts to a

From: Rod Moffitt
Subject: [avr-gcc-list] patch to fix unbalanced 'cli' that causes interrupts to always be disabled
Date: Sun, 1 Dec 2002 05:32:10 -0500 (EST)

While trying to create an interrupt based uart driver for an AVR mega128 I
discovered that interrupts were being turned off, almost randomly
throughout the code. After objdump'ing the image I observed dozens of cli
(global interrupt disable) opcodes. The cli opcodes are inserted prior to
SP (stack pointer) modification by gcc to prevent an interrupt from
corrupting the stack (which is not done atomically due to the 16 bit SP
being accessed a byte at a time, a limitation of the AVR). The problem is
that gcc doesn't always balance the cli with an sei (global interrupt
enable). This patch balances the cli by ensuring that a sei is inserted
after the SP modification whenever a cli was inserted. My application now
works as expected.

This patch is against gcc 3.3 that I downloaded from CVS on 20021127.
The file, gcc/config/avr/avr.c was last updated 5 weeks ago by denisc to
version 1.86.

- Rod

Attachment: patch
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]