interrupts go strange

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello
in my programm, after an interrupt, programm start
from the beginning..

...

SIGNAL (SIG_INT0) {
  OCR0A = 0xFF;    
 _delay_ms(10);
 compteur++;

OCR0A = 0x0;
}

...

      //**it's starting again here
OCR0A = 0xF;      // BLEU
 _delay_ms(1000);
OCR0A = 0x0;

 // turn on interrupts!

sei();
while(1){}
...

Got an idea?

computer : GNU Linux / e6750
ship : Attiny 2313 / ATmega8
compiler : avr-gcc 1:4.3.2-1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

we need to see more code. You have cut away too much for us to see what is going on.

What AVR are you using? (I'm guessing either a mega8, or tiny2313 from your signature)

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

Last Edited: Sun. Oct 18, 2009 - 05:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But resets when interrupts occur is often explained under the "catch-all" section of this page in the manual:

http://www.nongnu.org/avr-libc/u...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello
i put

ISR(INT0_vect) {

in place of

SIGNAL (SIG_INT0) { 

And it's working :)
it's at2113 with avrlib, on linux
Cool
But i don't understand why it workw now...

computer : GNU Linux / e6750
ship : Attiny 2313 / ATmega8
compiler : avr-gcc 1:4.3.2-1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What the SIGNAL() stands for? I always use ISR().

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SIGNAL() is the old way of doing ISR's with GCC. It is deprecated, and should not be used anymore.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My guess is that you only had:

#include 

rather than:

#include 
#include 

Because the SIGNAL() version, although deprecated, should still have worked for a 2313

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello !

I have ATmega324A and i am waking MCU up with INT1, it also sometimes starts from beginning, but MCUSR is clear.

Is there anything strange in my sleep or interrupt section?

Thanx!

Code fragments:

volatile unsigned char rWakedUpByButton = 0;

...

//wake up from sleep by push-button
ISR(INT1_vect)
{
//reconfigure to edge triggered or disable, else it will re-execute until button is down on level-triger mode
//EICRA |= (1<<ISC11);
EIMSK &= ~(1 << INT1);
rWakedUpByButton = 1;
}

And in main:

while(1)
{
cli(); //disable interrupts
EIMSK = 0;
//enable button interrupt
EICRA &= ~((1<<ISC11) | (1<<ISC10));
EIMSK |= (1 << INT1);
sei(); //Enable global interrupts

set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_mode();// here the device is actually put to sleep!!
// THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP----------------------------
sleep_disable();

...
//Do other things here, not INT related

rWakedUpByButton = 0;

}