Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 11th February 2009, 08:04 PM   #1
Default How to set a function in a certain address?

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!
alphadog is offline  
Old 11th February 2009, 08:58 PM   #2
Default

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 by dknguyen; 11th February 2009 at 08:58 PM.
dknguyen is offline  
Old 11th February 2009, 09:11 PM   #3
Default

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.
alphadog is offline  
Old 11th February 2009, 09:14 PM   #4
Default

I don't know anything about that processor.
dknguyen is offline  
Old 11th February 2009, 09:50 PM   #5
Default

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.
alphadog is offline  
Old 11th February 2009, 10:10 PM   #6
Default

YOu can write sections of assembly in C you know.

I think you use asm{...} or something like that.
dknguyen is offline  
Old 11th February 2009, 10:22 PM   #7
Default

Yes but the whole other code is written in C, so implementing single asm file in the code wouldn't be a good idea.
alphadog is offline  
Old 11th February 2009, 11:18 PM   #8
Default

You don't need asm. What compiler and have you read the manual.?
colin mac is offline  
Old 12th February 2009, 08:13 AM   #9
Default

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.
__________________
We never have time to do it right; but we always have time to do it over.
Papabravo is offline  
Reply

Tags
address, function, set

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Incrementing Register Address?? Suraj143 Micro Controllers 2 8th December 2008 02:30 AM
want an address sequence file srujan Electronic Projects Design/Ideas/Reviews 4 10th March 2008 11:59 AM
address 0x000 aljamri Micro Controllers 0 25th May 2007 10:19 AM
MAC address problem tkvenki Micro Controllers 4 22nd March 2007 09:25 AM
Function Generator question: What is GATE function? Cifrocco General Electronics Chat 8 14th April 2005 04:11 AM



All times are GMT. The time now is 02:18 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker