This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I just started using Code Composer Studio V4, and ran into difficulties trying to define an interrupt handler. I'm using an MSP430F1611, and the MSP430x16x.h file defines a macro called ISR_VECTOR(func,offset). It looks like I should just be able to put
interrupt void my_isr(void);
ISR_VECTOR(my_isr,PORT1_VECTOR)
in my code and then define the function, and it should work. It doesn't. I tracked it down, and it turns out there are two problems in the header file. First, the ISR_VECTOR macro relies on other macros, which rely on others, and so on. Unfortunately, the rules for when macros are expanded are a bit tricky, and they don't get expanded properly here. So I expanded this manually, and got:
interrupt void my_isr(void);
void (* const my_isr_ptr)(void) =
&my_isr;
#pragma DATA_SECTION(my_isr_ptr,PORT1_VECTOR)
This solves the replacement problem, but unfortunately it still doesn't work right. It turns out that PORT1_VECTOR is defined as ".int4", whereas the section defined in lnk_msp_430f1611.cmd is defined as ".int04". Rewriting the last line to
#pragma DATA_SECTION(my_isr_ptr,".int04")
solved this problem, and then I was off and running. I hope others with these issues will find this helpful.
Hi Jonathan,
an interrupt simply looks like:
#pragma vector=PORT1_VECTOR
__interrupt void myport1_isr(void)
Pls note the two unterlines in front of the interrupt instrinsic!
Rgds
aBUGSworstnightmare
P.S. Why do you want to place yur ISR in DATA_SECTION instead of CODE_SECTION?
aBUGSworstnightmare,
Thanks for taking the time to help me out. I have so say, though, I'm still rather confused. It seems that either the msp430x16x.h header file that ships with CCSv4 is worse off than I thought, or maybe the ISR_VECTOR macro is for something completely different. Do you know what the ISR_VECTOR macro is for? As to the pragma syntax you suggested, PORT1_VECTOR is defined in msp430x16x.h as ".int4", and the preprocessor complains that the vector pragma expects an integral type. I'm assuming that it wants the address of the interrupt, which is FFE8, but if I #pragma vector=0xffe8 then it complains that it's creating an output section .int65506 without a SECTIONS specification. There is a SECTIONS specification in the lnk_msp43f1611.cmd file that ships with CCSv4, and it calls that section .int04! So I've still got it wrong, I'm still not sure how to do it right.
On a different note, the reason that I used DATA_SECTION instead of CODE_SECTION was because that's what the macro used, but now that you mention it, it does seem rather silly. Again I have to wonder if the macro has a third error in it or if I'm totally misunderstanding what it's for.
Finally, I spent a bunch of time digging around for a manual to CCSv4 and have yet to come up with anything remotely comprehensive. Do you know if there is such a thing? Where is it? If there's not, do you know if there's at least some documentation of how to define an interrupt handler in CCSv4? I've found examples for CCE, IAR, and several others, but nothing for CCSv4.
Again, thanks for your help!
Jonathan
Ahh. I think I just figured out the answer to the first paragraph in my above post. To connect a function to .int4, the syntax is
#pragma vector=4
__interrupt void isr() {...}
I understand your reply now, and it indeed compiles. I won't have a jtag until Wednesday so I can't try it out quite yet, but for the moment I'll take your word for it. I still would like to know about documentation and if you have any idea what's up with the macro in the .h file...
Jonathan