MC9S08SG4 and interrupts

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MC9S08SG4 and interrupts

3,389 次查看
jag
Contributor IV
Hello,
I'm porting a old program made for QY4 to the new SG4 chip.
I'm using CW6.1 without Processor Expert.

The question is:
how can I declare ISR (in C, no assembly, no PE)?

for QY it was something like:

#pragma TRAP_PROC
void ADC_Isr(void)
{
//code
}

and in the linker.prm the isr is declared like this:

VECTOR 16 ADC_Isr

For the SG4 I found no examples, and in the mc9s08sg4.h I found some #define that could be useful, but I've no idea how to use them.

Any help?

Thanks

Bye Jack
标签 (1)
标记 (1)
0 项奖励
回复
5 回复数

1,273 次查看
J2MEJediMaster
Specialist I
The same technique should work. Do you have the right header file for that particular MCU?

---Tom

0 项奖励
回复

1,273 次查看
jag
Contributor IV
Yes, it works thanks. Or at least it compile. I've not yet the board under my hands, so I can't try.

Another question:

I've found in an example (from another HCS08 processor) that is possible to declare interrupts like this:

__interrupt VectorNumber_Vadc void ADC_Isr(void)
{
    //code
}

where VectorNumber_Vadc is the interrupt vector number.
I think this is preferable, because with the other method I still need to edit the .prm file. Instead with this all the info needed for this interrupt are in .c files. So is more readable.

So what do you think? It's better to use #pragma TRAP_PROC or __interrupt?

Thanks

Bye Jack
0 项奖励
回复

1,273 次查看
J2MEJediMaster
Specialist I
I think both arrangments accomplish the same thing. See what works, and if you have a choice, then use the scheme that you prefer.

---Tom
0 项奖励
回复

1,273 次查看
bigmac
Specialist III
Hello Jack,
 
The various alternative methods available for implementing interrupt handlers within CW, are outlined in AN2616, within the FAQ section.
 
Regards,
Mac
 
0 项奖励
回复

1,273 次查看
jag
Contributor IV
Hi,
thanks to both.

Probably at the beginning the #pragma TRAP_PROC instruction didn't work because another error in the code :smileytongue:

Bye Jack
0 项奖励
回复