ATMEGA 644 on Pollin NETIO: sei leads to reset/restart

OP #3851451
Hello all,

first of all: I hope that this is the correct forum, if not, please give 
me a hint.
2nd: I searched a couple of days, but did not find anything, so now, I 
need someone who likes to help me.

I run an Atmel ATMEGA 644 on a Pollin Net-I/O board and try "from 
scratch" to setup a simple timer 0 interrupt.

The code looks like this:
1
#include <stdint.h>
2
#include <avr/io.h>
3
#include <avr/interrupt.h> 
4
#include <util/delay.h>
5

6
ISR(BADISR_vect)
7
{
8
// catch up all interrupts for which no ISR is defined
9
}
10

11
ISR (TIMER0_OVF_vect) 
12
{
13
  PORTC |= (1<< PC1);           // LED on
14
  _delay_us(200);
15
  PORTC &= ~(1<< PC1);          // LED off
16
}
17

18
// ********************** main function **************************
19
int main(void) {        // main function begins here
20

21
  DDRC |= (1<<PC0) | (1<<PC1); // set C.0 and C.1 as output  
22

23
  TCCR0B = 1<<CS02;
24
  TIMSK0 |= (1<<TOIE0);        // unmask timer0 interrupt
25

26
  sei();                       // enable interrupts 
27
   
28
  for (;;) {
29
    PORTC |= (1<<PC0);         // LED on
30
    _delay_ms(200);
31
    PORTC &= ~(1<<PC0);        // LED off
32
    _delay_ms(200);
33
  
34
  }
35

36
  return (0);    // return from function main (never reached)
37

38
}

The strange thing is that the code after sei() is never reached, means 
the LED 0 is never blinking. If I comment out the sei() OR the TCCR0B = 
line, the LED 0 blinks.
(LED 1 stays dark in both cases)

If I try to use "external clock source on T0 Pin" (CS02 | CS01) the code 
"LED 0" is also reached, but obviously the ISR is not executed.

I also tried to configure Timer 1 with the same effect.

IMHO, the problem must be very trivial, but I don't have any clue 
anymore.

I really appreciate some ideas / hints from you, TIA!
OP #3853100
I set this myself to "Solved" (is there a formal way?).

As I found out today, I was a little bit confused, when I took over my 
makefile from another project (Bootloader), so this code was flashed 
into the bootloader section. Sure, interrupts in Bootloader are also 
possible, but need another interrupt tale. But, as I was using the 
"appl-interrupt table", the code could not work.

Removing the option LDFLAGS += -Ttext=E000 from the makefile did the 
trick, the code above is completely correct.

This, just that no one else uses his/her time to analyze my (phantom) 
problems!

Reply

A question of your own? This thread is over 12 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.