|
在C语言的中断函数里调用汇编函数一直在中断里出不来
[复制链接]
在C语言写的中断里调用了下汇编写的函数,单步运行的时候有可能会出现一直卡在中断里出不来,这是什么原因?出现这种情况都是刚烧写到单片机里,进入中断后单步运行。这是什么情况?当汇编函数无参数时上述情况就不会出现了。
汇编函数代码:
#include "msp430f5438a.h"
PUBLIC fir
RSEG CODE
EXTERN hn
EXTERN an
EXTERN bn
EXTERN cn
EXTERN dn
EXTERN sum_w
EXTERN sum_x
EXTERN sum_y
EXTERN sum_z
EXTERN n
fir:
push.w R10
push.w R11
mov.w #33,n
mov.w hn,R11
/*mov.w an,R12
mov.w bn,R13
mov.w cn,R14
mov.w dn,R15*/
ADw:
mov.w @R11,MPYS
mov.w @R12,OP2
NOP
add.w RESLO,sum_w
add.w RESHI,&sum_w+2
ADx:
mov.w @R11,MPYS
mov.w @R13,OP2
NOP
add.w RESLO,sum_x
add.w RESHI,&sum_x+2
ADy:
mov.w @R11,MPYS
mov.w @R14,OP2
NOP
add.w RESLO,sum_y
add.w RESHI,&sum_y+2
ADz:
mov.w @R11,MPYS
mov.w @R15,OP2
NOP
add.w RESLO,sum_z
add.w RESHI,&sum_z+2
incd R11
decd R12
decd R13
decd R14
decd R15
dec n
CMP #0,n
JNE ADw
pop R11
pop R10
reta
END
C语言代码:
#include "msp430x54x.h"
extern long fir(int *,int *,int *,int *);
long sum_w=0,sum_x=0,sum_y=0,sum_z=0;
int a[33];
int b[33];
int c[33];
int d[33];
int h[33];
int n;
int i;
int *hn;//,*an,*bn,*cn,*dn;
void dco_config()
{
__bis_SR_register(SCG0);
UCSCTL0 = 0x0000;
UCSCTL1 = DCORSEL_7;
UCSCTL2 = FLLD_1 + 762;
__bic_SR_register(SCG0);
__delay_cycles(25000);
}
void TimerA_config()
{
TA0CTL |= TASSEL_2+MC_1;
TA0CCR0 = 12500;
TA0CCTL0=CCIE;
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
dco_config();
TimerA_config();
P3DIR |= 0x10;
P3OUT = 0x10;
for(i=0;i<33;i++)
{
a[i]=i;
b[i]=i;
c[i]=i;
d[i]=i;
h[i]=i;
}
hn=h;
/*an=&a[32];
bn=&b[32];
cn=&c[32];
dn=&d[32];*/
_EINT();
while(1)
{
int j=0;
for(;j<100;j++);
/*P3OUT=~P3OUT;
fir(&a[32],&b[32],&c[32],&d[32]);*/
}
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer0_A5()
{
P3OUT=~P3OUT;
fir(&a[32],&b[32],&c[32],&d[32]);
P3OUT=~P3OUT;
}
|
|