ATmega32 interrupt priorities

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

Page 43 in ATmega32.pdf implies (to me) that the interrupt priorities could be changed.

“The most typical and general program setup for the Reset and Interrupt Vector Addresses in ATmega32 is:”

Can they be changed by re-ordering them in iom32.h?

Also, in iom32.h the interrupt vectors are defined as follows:
#define SIG_INTERRUPT0 _VECTOR(1)
etc.

but where is _VECTOR(1), etc. found? I have searched the whole WinAVR folder.

Thanks,
davef

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

You can't change the Interupt vector priority. Your best bet would be to have the vectors in question jump to a common routine and determine which Interupt was triggered there.

-Curiosity may have killed the cat
-But that's why they have nine lives

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

Thank you. I guess there is not much point in worrying about where _VECTOR(1) would be found then :)

davef

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

The Interrupt vectors are located in the lower memory area (starting at address 00 for the reset) of the Flash.
Where they point to is a function of the compiler/size of programe.

Keep it simple it will not bite as hard

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

Sorry, I meant to ask where is the label _Vector(1) found.
Which file? It must be a previously #defined value somewhere.

Cheers,
davef

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

$WINAVR/avr/include/avr/sfr_defs.h

it's defined weirdly!

#define _VECTOR(N) __vector_ ## N

I prefer to think of it as of magic, but in fact it's just a syntax chosen by gcc team to tell the compiler that we're dealing with an absolute location in memory.

The Dark Boxes are coming.

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

davef wrote:
where is the label _Vector(1) found

It's not a label. _VECTOR(N) is a macro. In the file sfr_defs.h You will find

#ifndef _VECTOR
#define _VECTOR(N) __vector_ ## N
#endif

The "##" is no magic, and not specific for AVR-GCC. Its the C preprocessor "stringizing operator" (Google it!).
so

_VECTOR(1)

simply expands to

__vector_1

and thus

#define SIG_INTERRUPT0 _VECTOR(1)

expands to

#define SIG_INTERRUPT0 __vector_1

So now the question becomes: How is "__vector_1" handed by the compiler (it is not defined in any header file as far as I can tell). I don't know the answer to that. We'll have to wait for the heavy-weight gurus for this. Where are You, Jörg?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Quote:
So now the question becomes: How is "__vector_1" handed by the compiler (it is not defined in any header file as far as I can tell). I don't know the answer to that.

I told you it's magic! :P

The Dark Boxes are coming.

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

Hello,

That's not part of the headers. The jump table with the interrupt vectors is glued by default at linking time with the compiler initialization stuff (ram variable initialization, stack placing, zero register clearing,...). If you want to see the source code, it's contained in the avr-libc sources in gcrt1.S in http://savannah.nongnu.org/proje...

The "magic" is the weak definition of the __vector_n symbols pointing by default to __vector_default in gcrt1.S. Then, if the programmer does not define the corresponding ISR (ie, a function named __vector_n) the jump table will contain an entry to __vector_default, defined itself also as a weak symbol by default identical to the reset vector. This way all the undefined interrupt vectors will jump to the reset vector.

Well, this explanation it's really harder to understand than the code in gcrt1.S ;-)

Regards,

Carlos.

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

Thanks guys. There was a lot more to this than I first thought!

I had been working with "another" part that has 11 ports that can be used for interrupt purposes, all of which can be re-prioritised. When I realised the ATmega32 has only 3 external interrupt ports AND none of the interrupts appeared to be able to be re-prioritised I thought I had better get a better understanding what the capabilities were on this device.

Thanks again for taking the time to explain the issue in appropriate detail.

Cheers,
davef