#include "DSP28_Device.h"
unsigned int Send_Flag;
unsigned int i;
char *strg="abcd";
unsigned int count;
void printftest()
{
length=5;
length--;
Tx=(unsigned char*)strg;
if(length>0) SciaRegs.SCITXBUF=*Tx++;
else
{
length=0;
}
}
void DelayNmSec(int N)
{
unsigned int j;
while(N--)
for(j=0;j<65535;j++);
}
interrupt void WAKEINT_ISR(void)
{
if(count>=0xfff0)count=0;
count++;
printftest();
PieCtrl.PIEACK.bit.ACK1=1;
EINT;
}
void EnableDog(void)
{
EALLOW;
SysCtrlRegs.WDCR = 0x002f;
EDIS;
}
void DisableDog(void)
{
EALLOW;
SysCtrlRegs.WDCR = 0x006f;
EDIS;
}
void KickDog(void)
{
EALLOW;
SysCtrlRegs.WDKEY=0x0055;
SysCtrlRegs.WDKEY=0x00AA;
EDIS;
}
void main(void)
{
/*初始化系统*/
InitSysCtrl();
/*关中断*/
DINT;
IER = 0x0000;
IFR = 0x0000;
/*初始化PIE中断*/
InitPieCtrl();
/*初始化PIE中断矢量表*/
InitPieVectTable();
/*初始化SCIA寄存器*/
InitSci();
for(i = 0; i < 8; i++)
{
Sci_VarRx[i] = 0;
Sci_VarTx[i] = 0;
}
Rx=Sci_VarRx;
Tx=Sci_VarTx;
Send_Flag = 0;
rx_length=0;
add=0;
length=9;
count=0;
/*设置中断服务程序入口地址*/
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TXAINT = &SCITXINTA_ISR;
PieVectTable.RXAINT = &SCIRXINTA_ISR;
PieVectTable.WAKEINT = &WAKEINT_ISR;
EDIS; // This is needed to disable write to EALLOW protected registers
PieCtrl.PIECRTL.bit.ENPIE = 1; // Enable the PIE block
PieCtrl.PIEIER1.bit.INTx8 = 1; // Enable PIE Gropu 1 INT8
EALLOW;
SysCtrlRegs.SCSR.bit.WDOVERRIDE=1;//允许通过WDDIS位禁止
SysCtrlRegs.SCSR.bit.WDENINT=1;//0 dsp复位 1 产生WDINT中断,在用仿真器时,看不到复位结果
EDIS;
/*开中断*/
IER |= M_INT9;
IER |= M_INT1; // Enable CPU INT1
EINT; // Enable lobal interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
printftest();
// Reset the watchdog counter
KickDog();
// Enable the watchdog
EnableDog();
while(1)
{
}
}
//===========================================================================
// No more.
//===========================================================================
看门狗的复位和中断的选择:SysCtrlRegs.SCSR.bit.WDENINT为1,中断;为0,产生复位;
当使用仿真器时不要给板子复位;
阅读(4377) | 评论(0) | 转发(0) |