|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 cjsb37 于 2013-4-29 09:08 编辑
#include "DSP281x_Device.h"
#include "DSP281x_Examples.h"
void scia_init(void);
void fifo_init(void);
interrupt void scia_rx_isr(void);
interrupt void scia_tx_isr(void);
char message[]={"this is 2812.\n\r"};
void main(void)
{
InitSysCtrl();
EALLOW;
GpioMuxRegs.GPFMUX.all=0x0030;
EDIS;
DINT;
IER = 0x0000;
IFR = 0x0000;
InitPieCtrl();
InitPieVectTable();
EALLOW;
PieVectTable.TXAINT=&scia_tx_isr;
PieVectTable.RXAINT=&scia_rx_isr;
EDIS;
PieCtrlRegs.PIEIER9.bit.INTx2=1;
PieCtrlRegs.PIEIER9.bit.INTx1=1;
IER|=M_INT9;
EINT;
ERTM;
fifo_init();
scia_init();
while(1)
{
}
}
void scia_init()
{
SciaRegs.SCICCR.all =0x0007;
SciaRegs.SCICTL1.all =0x0003;
SciaRegs.SCICTL2.all =0x0003;
SciaRegs.SCIHBAUD =0x0001;
SciaRegs.SCILBAUD =0x00e7;
SciaRegs.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
SciaRegs.SCICCR.bit.LOOPBKENA =0;
SciaRegs.SCICTL1.all =0x0023;
//SciaRegs.SCICTL1.bit.SWRESET =1;
}
void fifo_init()
{
SciaRegs.SCIFFTX.all =0xC060;
SciaRegs.SCIFFRX.all =0xE065;
SciaRegs.SCIFFCT.all =0x0000;
}
interrupt void scia_tx_isr(void)
{
int i;
for(i=0;i<16;i++)
SciaRegs.SCITXBUF=message;
PieCtrlRegs.PIEACK.all=PIEACK_GROUP9;
}
interrupt void scia_rx_isr(void)
{
int i;
char buffer[16];
for(i=0;i<16;i++)
buffer=SciaRegs.SCIRXBUF.all;
if(strncmp(buffer,"who is there?",13)==0)
{
SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
SciaRegs.SCIFFTX.bit.TXINTCLR=1;
}
SciaRegs.SCIFFRX.bit.RXFIFORESET=0;
SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;
PieCtrlRegs.PIEACK.all=PIEACK_GROUP9;
}
程序编译和运行都能通过,为什么用串口小助手却收不到DSP发的信息呢?请高手指点!非常感谢!
还可以发送到我的邮箱里:tsangjoewong@163.com
|
|