moving to specific point in code after interrupt

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

moving to specific point in code after interrupt

1,701 次查看
sams
Contributor I

Hello
I am having trouble with creating edge-triggered interrupt which ll "jump" program to a specific point in my main function. Here is my simplified code and what i want to achive:

main.c  :
function1{}
function2{}

void main(void){
 <=== interrupt occurs while function1 is executing and i want to "jump" in front of it so it could be executed from the begining.
function1{}
}


interrupts.c  :
#pragma CODE_SEG DEFAULT
void Int1(void)
{
function2{}
}

void Int2(void)
{
function2{}
}

Thanks in advance for help

标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

1,019 次查看
CrasyCat
Specialist III

Hello

 

- Which CPU are you targeting (HC08, HC12, Coldfire, ..)
- Which version of CodeWarrior are you using?
To retrieve that info:
- Start CodeWarrior
- Select Help -> About Freescale CodeWarrior
- Click on "Install Products"
- CodeWarrior version used is displayed on top in the Installed Products dialog.

 

 Why can't you use the standard Return from Interrupt mechanism from the chip here and go back where you have been interrupted?

 

 Do you always need to return in front of function1 invocation or you need to return in front of whatever function was executing when the interrupt occurs?

 

CrasyCat

0 项奖励
回复

1,019 次查看
sams
Contributor I

Thx for the reply

 

I am using CodeWarrior for the S12(X) v5.0 build 9061

My CPU is HCS12NE64 exactly

 

Generaly function1 here is sending some data to external device. I need a possibility to stop that at any time and later trigger this function again but for example with different parameters.

 

To the last question I always need to return to the same place in main function  no matter what function was executing when the interrupt happend.

0 项奖励
回复

1,019 次查看
kef
Specialist I

Though this idea to jump from ISR seems weird for me, maybe try setjmp() + longjmp()? Looking at library source, setjmp.c and setjmp.h, it seems longjmp restores PPAGE, PC and SP. It is almost all you need to jump from S12 ISR. What longjmp doesn't restore is status register I bit (and on S12X - interrupt priority level). To fill this gap you can either reenable interrupts before longjmp call in ISR, or reenable interrupts in main(), just after setjmp call. (On S12X you would also need to restore IPL in CPU status register).

 

0 项奖励
回复