-
Jan 19th, 2012, 06:19 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] void pointer to interrupt function
Hi All
I am working with Hi-Tech's HC51-Lite compiler...its a nightmare.
I am trying to assign an ISR to run on a certain interrupt vector.
The Hi-Tech manual recommends a couple techniques only one of which works in my version: using inline asm code. The asm code means I need obtain a pointer to the ISR so I can place this in the ACC and thus reference it in the asm section.
My current C code to do this is:
Code:
// ISR name= interrupt void ext1isr (void)
void (*pisr)(void);
pisr = &ext1isr; // Line 23
ACC = ((int*)pisr); // Line 24
But the compiler gives me errors:
Error : 23 undefined identifier "ext1isr"
Warning : 23 illegal conversion between pointer types
Warning : 24 illegal conversion of pointer to integer
Frankly void pointers and pointers to functions are outside my level of knowledge so any help much appreciated.
Thanks
EDIT: just tried: interrupt voide (*pisr) (void); but no change
Last edited by wolf99; Jan 19th, 2012 at 06:23 AM.
Thanks
-
Jan 19th, 2012, 07:04 AM
#2
Re: void pointer to interrupt function
I have never used that compiler but I'll try to assist the best I can.
What is ext1isr in this context?
-
Jan 19th, 2012, 07:49 AM
#3
Lively Member
Re: void pointer to interrupt function
You check ext1isr variable, it's not been declared in code scope.
-
Jan 19th, 2012, 09:15 AM
#4
Thread Starter
Hyperactive Member
Re: void pointer to interrupt function
@Athiest
Originally Posted by wolf99
Code:
// ISR name= interrupt void ext1isr (void)
ext1isr is the function. Im trying to make a pointer to a function.
So I have the rest of the pointer manipulation working bar trying to assign the functions address to the pointer.
In Keil C (and ANSI C AFAIK) the code would be this:
Code:
pIsr = &functionName;
Which is what seems to be throwing the only error that functionName is an undefined identifier....
I placed the ISR function above the main() in the file and the error leaves but is replaced by a warning: "redundant "&" applied to function" which makes me think that what is happening here is that the program is actually calling the function and expecting a variable to be returned that will then be placed in the variable pISR, some thing like if I had written:
Code:
int x = add(5,5) // expect x = 10
*sigh*
Thanks
-
Jan 19th, 2012, 09:29 AM
#5
Re: void pointer to interrupt function
Is the method defined in the same code file as the containing the code of your first post? Have you placed a function declaration at the top of your code?
Code:
void ext1isr(void);
You probably already know this, but if you omit this declaration, the order of which the methods are written suddenly becomes important, because you can not refer to a method defined further down in your source code.
Originally Posted by wolf99
I placed the ISR function above the main() in the file...
With the ISR function being ext1isr, and main containing the code snippet from the first post? Have you tried simply removing the ampersand from your assignment? I just tried with gcc and it allows function pointer assignment to be done both with and without the ampersand. Perhaps your compiler only supports the latter.
Code:
pIsr = functionName;
-
Jan 19th, 2012, 09:44 AM
#6
Thread Starter
Hyperactive Member
Re: void pointer to interrupt function
Hi Athiest
Thanks, I had neglected to declare the isr *facepalm*
So Ive removed the & and the warning has gone...
... checking in memory view... and yes the right values are in the DPTR
Many Thanks!
(now I just need to get my LJUMP right..oh I see youve answered that t0o! coolio!)
Last edited by wolf99; Jan 19th, 2012 at 09:53 AM.
Thanks
-
Jan 19th, 2012, 09:50 AM
#7
Re: void pointer to interrupt function
Great!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|