What is the type of the __vector_x function?

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

As explained in this link: 

https://www.avrfreaks.net/forum/...

 

`__vector_x` has a weak symbol which can be overwritten by a user for setting interrupt callbacks.

 

There is a comment in the above link which states the following:

so that defines a void (*)(void) called __vector_5 and then this all links back to my earlier post ...

To my understanding, this comment is saying  `__vector_5` is function pointer which takes in no args and returns nothing?

 

But `__vector_5` is not a function pointer, it's a normal function of type `void(void)`. Is the above comment a mistake or I need to learn something new today?

 

I know that a functions name can also be thought of as a pointer to an address, so not sure if it's related to that.

 

This topic has a solution.
Last Edited: Mon. Jan 3, 2022 - 06:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avruser1523 wrote:
function pointer which takes in no args and returns nothing

that has to be the case, as ISRs are called direct from hardware - so there is nowhere for them to receive parameters from, and nowhere to return anything to.

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avruser1523 wrote:

As explained in this link: 

https://www.avrfreaks.net/forum/...

 

`__vector_x` has a weak symbol which can be overwritten by a user for setting interrupt callbacks.

 

There is a comment in the above link which states the following:

so that defines a void (*)(void) called __vector_5 and then this all links back to my earlier post ...

To my understanding, this comment is saying  `__vector_5` is function pointer which takes in no args and returns nothing?

 

But `__vector_5` is not a function pointer, it's a normal function of type `void(void)`. Is the above comment a mistake or I need to learn something new today?

 

Yes, the comment is a mistake or some sort of miswording.

 

`__vector_5` is not a pointer. It is a genuine function. It has a definition in the support library. However, there it is defined as a weak symbol. This means that you can replace it with your own "strong" symbol (which is exactly what you do when you define your own handler).

 

One can find some similarities with function pointers, but these similarities are very remote. "Function pointer" is a language-level concept, while "weak symbol" is a linker-level concept. These are two very different worlds.

Dessine-moi un mouton

Last Edited: Mon. Jan 3, 2022 - 06:53 PM