//###########################################################################
//
// FILE : 281x-SCI_PC.c
//
// TITLE: 281x-SCI和PC间的通讯 --- 查询方式,使用FIFO
// PC发送至串口,DSP再回送至PC //
//
// ASSUMPTIONS:
//
// As supplied, this project is configured for "boot to H0" operation.
// Other then boot mode pin configuration, no other hardware configuration is required.
//
//###########################################################################
# include "DSP281x_Device.h" // DSP281x Headerfile Include File
# include "DSP281x_Examples.h" // DSP281x Examples Include File
void scia_echoback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a); //串口发送--数据
void scia_msg(char *msg); //串口发送--字符串
Uint16 LoopCount;
InitPieCtrl(); //初始化PIE控制寄存器
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable(); //初始化PIE中断向量表
// Step 4. Initialize all the Device Peripherals:
// InitPeripherals(); //初始化所有外设
// Step 5. User specific code:
scia_fifo_init();
scia_echoback_init();
//从PC上的串口调试助手输入要发送的数据至DSP
msg = "/r/nYou will enter a character, and the DSP will echo it back! /n/0";
scia_msg(msg);
for(;;)
{
msg = "/r/nEnter a character: /0";
scia_msg(msg);
// 查询方式--接收--使用FIFO
while(SciaRegs.SCIFFRX.bit.RXFIFST!=1) { } // wait for XRDY =1 for empty state
//XRDY =1 (空状态)等待数据发送
// 接收数据
ReceivedChar = SciaRegs.SCIRXBUF.all;
// Echo character back
msg = " You sent: /0";
scia_msg(msg);
scia_xmit(ReceivedChar); //串口发送函数
LoopCount++;
} //end for
} //end main