avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] gcc-avr 4.9.2 -Os messes with interrupt vectors


From: Parthasaradhi Nayani
Subject: Re: [avr-gcc-list] gcc-avr 4.9.2 -Os messes with interrupt vectors
Date: Sun, 8 May 2016 09:22:31 +0000 (UTC)

First off, you are disabling global interrupts (cli ()). You need to enable them (sei ()). I presume you are toggling the LED in ISR, if so the LED will not toggle as interrupts are disabled. 
 
Regards,
Parthasaradhi
Hyderabad


On Sunday, May 8, 2016 2:40 PM, "address@hidden" <address@hidden> wrote:


Hello,

I have been working on a project for some time and at some point, everything just stopped working. It appears that as soon as I include an ISR in my C code, the main function won't even be called anymore. I reduced my code to this:


#include <avr/io.h>
#include <avr/interrupt.h>

int main (void) {
  cli();
  DDRB = 0xff;
  while(1) PORTB |= (1 << PB5);
  return 0;
}

ISR(TIMER0_OVF_vect) {}

But the LED just won't turn on. The strange thing is: If I remove the ISR at the bottom without changing anything else, even keeping the include, everything works. If I remove the -Os option from gcc but keep the ISR, everything works.

I use these commands to compile, link and flash it:

F_CPU=16000000L
avr-gcc -Wall -DF_CPU=$F_CPU -c -mmcu=atmega168 -Os main.c -o main.o
avr-ld -mavr5 -o led-test.elf main.o
avr-objcopy -O ihex led-test.elf led-test.hex
sudo avrdude -c avrisp2 -p atmega168 -P usb -b 57600 -U flash:w:led-test.hex


I am quite new to the avr tools so I might just have made a silly mistake, so I would appreciate any tips!
Thank you!


LSB:
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:        16.04
Codename:       xenial

Output of avr-gcc -v:
Using built-in specs.
Reading specs from /usr/lib/gcc/avr/4.9.2/device-specs/specs-avr2
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.9.2/lto-wrapper
Target: avr
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr CFLAGS='-g -O2 -fstack-protector-strong -Wformat ' CPPFLAGS=-D_FORTIFY_SOURCE=2 CXXFLAGS='-g -O2 -fstack-protector-strong -Wformat ' FCFLAGS='-g -O2 -fstack-protector-strong' FFLAGS='-g -O2 -fstack-protector-strong' GCJFLAGS='-g -O2 -fstack-protector-strong' LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro' OBJCFLAGS='-g -O2 -fstack-protector-strong -Wformat ' OBJCXXFLAGS='-g -O2 -fstack-protector-strong -Wformat '
Thread model: single
gcc version 4.9.2 (GCC)

_______________________________________________
AVR-GCC-list mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list



reply via email to

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