Board logo

标题: 8037实验程序中出现自动复位怎么办?? [打印本页]

作者: yyzzww    时间: 2008-8-22 10:41     标题: 8037实验程序中出现自动复位怎么办??

片子是8037,写的程序如下。目的是定时(1秒)控制一个发光二极管亮一次,但是在亮了11次后,EVM板上的6个二极管都复位(全亮)了,我原先在初始化程序里设置了六个管子是熄灭的。后来把时间改成5秒,结果亮了2次后,又复位了。也就是说在程序执行一定时间后就不执行了。请帮我找找问题所在吧。谢谢


/***********************************************
*功能:GPIOA0口驱动的发光二极管每个1秒钟闪烁一次
*芯片:8037
************************************************/
#include "MC56F803x.h"
#include "SUB.h"


/*函数名:delay()*/
/*形参:dtime */
/*作用:有效延时1ms */
void delay (unsigned int dtime)
{
unsigned int i;
for(;dtime>0;dtime--)
{
for(i=0;i<124;i++)
{
;
}
}
}

/*函数名:initgpioA() */
/*作用:初始化程序*/
void initgpioA ()
{
asm(bfclr #$0002,X:COP_CTRL);
asm(bfclr #$0001,X:GPIO_A_PEREN);
asm(bfclr #$0002,X:GPIO_A_PEREN);
asm(bfclr #$0004,X:GPIO_A_PEREN);
asm(bfclr #$0008,X:GPIO_A_PEREN);
asm(bfclr #$0010,X:GPIO_A_PEREN);
asm(bfclr #$0020,X:GPIO_A_PEREN);
asm(bfset #$0001,X:GPIO_A_DDIR);
asm(bfset #$0002,X:GPIO_A_DDIR);
asm(bfset #$0004,X:GPIO_A_DDIR);
asm(bfset #$0008,X:GPIO_A_DDIR);
asm(bfset #$0010,X:GPIO_A_DDIR);
asm(bfset #$0020,X:GPIO_A_DDIR);
asm(bfclr #$0001,X:GPIO_A_DATA);
asm(bfclr #$0002,X:GPIO_A_DATA);
asm(bfclr #$0004,X:GPIO_A_DATA);
asm(bfclr #$0008,X:GPIO_A_DATA);
asm(bfclr #$0010,X:GPIO_A_DATA);
asm(bfclr #$0020,X:GPIO_A_DATA);

}

/*函数名:main() */
/*作用:主程序*/
void main (void)
{
initgpioA ();
while(1)
{
asm(bfchg #$0001,X:GPIO_A_DATA);
delay(1000);

}

}


下面是MC56F803x_vector.asm文件的一部分。我在调试时看到程序停到
MC56F803x_intRoutine:
debughlt
nop 处。

下面是完整的MC56F803x_vector.asm文件。

; sample code

; interrupt vectors for MC56F803x


section interrupt_routines
org p:

MC56F803x_intRoutine:
debughlt
nop
nop
rti


; illegal instruction interrupt($04)

MC56F803x_illegal:
debughlt
nop
nop
rti


; hardware stack overflow interrupt ($08)

MC56F803x_HWSOverflow:
debughlt
nop
nop
rti


; misaligned long word access interrupt ($0A)

MC56F803x_misalign:
debughlt
nop
nop
rti


; PLL lost of lock interrupt ($22)

MC56F803x_PLL:
debughlt
nop
nop
rti


endsec


section interrupt_vectors
org p:

global FMC56F803x_intVec

FMC56F803x_intVec:

jsr >Finit_MC56F803x_ ; RESET ($00)
jsr >MC56F803x_intRoutine ; COP Watchdog reset ($02)
jsr >MC56F803x_illegal ; illegal instruction ($04)
jsr >MC56F803x_intRoutine ; software interrupt 3 ($06)
jsr >MC56F803x_HWSOverflow ; hardware stack overflow ($08)
jsr >MC56F803x_misalign ; misaligned long word access ($0A)
jsr >MC56F803x_intRoutine ; EOnCE step counter ($0C)
jsr >MC56F803x_intRoutine ; EOnCE breakpoint unit 0 ($0E)
jsr >MC56F803x_intRoutine ; EOnCE trace buffer ($10)
jsr >MC56F803x_intRoutine ; EOnCE transmit register empty ($12)
jsr >MC56F803x_intRoutine ; EOnCE receive register full ($14)
jsr >MC56F803x_intRoutine ; software interrupt 2 ($16)
jsr >MC56F803x_intRoutine ; software interrupt 1 ($18)
jsr >MC56F803x_intRoutine ; software interrupt 0 ($1A)
jsr >MC56F803x_intRoutine ; reserved ($1C)
jsr >MC56F803x_intRoutine ; reserved ($1E)
jsr >MC56F803x_intRoutine ; Low Voltage Detector (power sense) ($20)
jsr >MC56F803x_PLL ; PLL ($22)
jsr >MC56F803x_intRoutine ; HFM Error Interrupt ($24)
jsr >MC56F803x_intRoutine ; HFM Command Complete ($26)
jsr >MC56F803x_intRoutine ; HFM Command, Data, and Address Buffers Empty ($28)
jsr >MC56F803x_intRoutine ; reserved ($2A)
jsr >MC56F803x_intRoutine ; GPIO D ($2C)
jsr >MC56F803x_intRoutine ; GPIO C ($2E)
jsr >MC56F803x_intRoutine ; GPIO B ($30)
jsr >MC56F803x_intRoutine ; GPIO A ($32)
jsr >MC56F803x_intRoutine ; SPI Receiver Full ($34)
jsr >MC56F803x_intRoutine ; SPI Transmtter Empty ($36)
jsr >MC56F803x_intRoutine ; SCI Transmitter Empty ($38)
jsr >MC56F803x_intRoutine ; SCI Transmitter Idle ($3A)
jsr >MC56F803x_intRoutine ; SCI Reserved ($3C)
jsr >MC56F803x_intRoutine ; SCI Receiver Error ($3E)
jsr >MC56F803x_intRoutine ; SCI Receiver Full ($40)
jsr >MC56F803x_intRoutine ; I2C Arbitration Lost ($42)
jsr >MC56F803x_intRoutine ; I2C Byte Transfer ($44)
jsr >MC56F803x_intRoutine ; I2C Address Detect ($46)
jsr >MC56F803x_intRoutine ; Timer Channel 0 ($48)
jsr >MC56F803x_intRoutine ; Timer Channel 1 ($4A)
jsr >MC56F803x_intRoutine ; Timer Channel 2 ($4C)
jsr >MC56F803x_intRoutine ; Timer Channel 3 ($4E)
jsr >MC56F803x_intRoutine ; ADCA Conversion Complete ($50)
jsr >MC56F803x_intRoutine ; ADCB Conversion Complete ($52)
jsr >MC56F803x_intRoutine ; ADC Zero Crossing or Limit Error ($54)
jsr >MC56F803x_intRoutine ; Reload PWM ($56)
jsr >MC56F803x_intRoutine ; PWM fault ($58)
jsr >MC56F803x_intRoutine ; SW interrupt Low Priority ($5A)


endsec

end


作者: yyzzww    时间: 2008-8-22 10:42

不要删文件




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0