关于DSP2812 SCI模块 中断方式发送接收的程序问题。 30

#include"DSP281x_Device.h"//DSP281xHeaderfileIncludeFile#include"DSP281x_Examples.h"/... #include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File
// Prototype statements for functions found within this file.
interrupt void sciaTxFifoIsr(void);
interrupt void sciaRxFifoIsr(void);
void scia_fifo_init(void);
Uint16 SciaRx_Ready(void);
Uint16 SciaTx_Ready(void);
// Global variables
Uint16 sdataA[8]; // Send data for SCI-A
Uint16 rdataA[8]; // Received data for SCI-A
void main(void)
{
Uint16 i;
InitSysCtrl();
EALLOW;
GpioMuxRegs.GPFMUX.bit.SCITXDA_GPIOF4 = 1;
GpioMuxRegs.GPFMUX.bit.SCIRXDA_GPIOF5 = 1;
EDIS;
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.RXAINT = &sciaRxFifoIsr;
PieVectTable.TXAINT = &sciaTxFifoIsr;
EDIS; // This is needed to disable write to EALLOW protected registers
scia_fifo_init(); // Init SCI-A
PieCtrlRegs.PIECRTL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER9.bit.INTx1=1; // PIE Group 9, INT1
PieCtrlRegs.PIEIER9.bit.INTx2=1; // PIE Group 9, INT2
IER |= M_INT9; // Enable CPU INT
EINT;
ERTM;
}
interrupt void sciaTxFifoIsr(void)
{
Uint16 i;
PieCtrlRegs.PIEACK.bit.ACK9 =1;

if(SciaTx_Ready()==1)
{
SciaRegs.SCITXBUF=rdataA[i]; // Send data
}
EINT;

}

interrupt void sciaRxFifoIsr(void)
{
Uint16 i;
PieCtrlRegs.PIEACK .bit .ACK9=1;//释放PIE同组中断
if(SciaRx_Ready()==1)
{
rdataA[i]=SciaRegs.SCIRXBUF.all; // Read data
}
EINT;//使能全局中断
}

void scia_fifo_init()
{
SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
SciaRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
SciaRegs.SCIHBAUD = 0x0001;
SciaRegs.SCILBAUD = 0x00e7;//9600
SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
SciaRegs.SCIFFTX.all=0xC028;
SciaRegs.SCIFFRX.all=0x0028;
SciaRegs.SCIFFCT.all=0x00;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
}
Uint16 SciaTx_Ready(void)
{
Uint16 i;
if(SciaRegs.SCICTL2.bit.TXRDY==1)
{
i=1;//返回1说明发送器已经转杯就绪可以进接收新的数据进行发送
}
else
{
i=0;
}
return(i);
}

Uint16 SciaRx_Ready(void)
{
Uint16 i;
if(SciaRegs.SCIRXST.bit.RXRDY==1)
{
i=1;//返回1说明接收准备就绪,等CPU读取数据
}
else
{
i=0;
}
return(i);
}

// No more.
//===========================================================================
展开
 我来答
jjjjjj000
2011-06-07
知道答主
回答量:3
采纳率:0%
帮助的人:0
展开全部
电风扇地方第三方速度山东肥城vxc
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式