Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to set a function in a certain address?

Status
Not open for further replies.

alphadog

Banned
I have a port that when any of its pin causes an interrupt, it vectors the MCU to address 0x7B.
I would like to create a new file, and write inside it a function, and have the function's address to be 0x7B.
I'd mention that i write the code in C language, not in assembly language.

How can i do that?

Thanks!
 
At least for PICs, there is a preset function name of some sorts that is at that memory address and gets called whenever the interrupt is triggered. You just declare the function using that name and type out your routine and it just runs whenever the interrupt fires. Check your compiler user manual about interrupts.
 
Last edited:
Thanks for the answer.
You suggest a nice way how to bypass the setting of a function in a ceratin address.
I'd still like to know how you do that, becuase i assume its possible.

By the way, i use the CC2430 MCU.
 
Alirght,
I know that if i used assembly language, i could use the command ' DSEG AT 0x7B '
and their i would be calling my function that serves interrupts.
I just dont know how to write it in C language.
 
YOu can write sections of assembly in C you know.

I think you use asm{...} or something like that.
 
Yes but the whole other code is written in C, so implementing single asm file in the code wouldn't be a good idea.
 
The IAR Compiler for the 8051 has an interrupt keyword that is used to bind a function to an interrupt vector.
Code:
interrupt [0x0023] using [SP_BANK] void SERIALISR(void)
{
...SERIALISR Code
}
It is common to declare an interrupt function as having no return value and taking no arguments. So 0x0023 is the absolute address of the serial port ISR inb all the 8051s you will ever see besides all the ones that you won't. The using qualifier selects one of 4 register banks to be used by the interrupt procedure.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top