Interrupt function placement

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

If I place the following in my source file that conatins main() it works properly.

RTC_1Hz_INTERRUPT_HANDLER(INT2_vect)
{
   RTC_a_second_has_passed = TRUE;
}

If I try to put it into another source file (RTC_ISR.c), I get errors that it doesn't know the return type of the function. I have a RTC_ISR.h as well as including all the relevant library files in RTC_ISR.c, ie and .

I have successfully included many other sources in my program, but there seems to be something different about interrupt function calls.

Could someone explain?

Thank you.

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

That's not the GCC interrupt syntax. In the latest LibC version, the syntax is:

ISR(vectorname)
{
 // ISR code goes here
}

Where "vectorname" is the name of the vector as shows in your AVR device's header file. For example, if the name of the interrupt was "INT2_vect", then the syntax would be:

ISR(INT2_vect)
{
// Code here
}

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

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

I think we are both saying the same thing, unless there is something special about the keyword ISR.

I just noticed that I didn't move an important line into the .h file

#define RTC_1Hz_INTERRUPT_HANDLER SIGNAL 

:oops:

I'll try again.

Thanks

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

In the latest avr-gcc, SIGNAL has been deprecated. Unless you are using an older version of avr-gcc, you should be using ISR.

Regards,
Steve A.

The Board helps those that help themselves.

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

Steve,

I am using WinAVR-20060421and it didn't make any difference whether you use SIGNAL or ISR. However, to be consistent I changed my #define to ISR.

Thanks guys, it works properly now.