#include "DSP28x_Project.h"
void scia_loopback_init(void);
void scia_fifo_init(void);
void error();
Uint16 LoopCount;
Uint16 ErrorCount;
Uint16 SendChar;
Uint16 ReceivedChar;
void main(void)
{
InitSysCtrl();
InitSciGpio();
DINT;
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
PieCtrlRegs.PIEACK.all = 0xFFFF;
EINT;
LoopCount = 0;
ErrorCount = 0;
scia_fifo_init();
scia_loopback_init();
SendChar = 0;
for(;;)
{
DELAY_US(1000000);
SciaRegs.SCITXBUF = SendChar;
while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { }
ReceivedChar = SciaRegs.SCIRXBUF.all;
if(ReceivedChar != SendChar) error();
SendChar++;
SendChar &= 0x00FF;
LoopCount++;
}
}
void error()
{
ErrorCount++;
}
void scia_loopback_init()
{
SciaRegs.SCICCR.all =0x0007;
SciaRegs.SCICTL1.all =0x0003;
SciaRegs.SCICTL2.all =0x0003;
SciaRegs.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
SciaRegs.SCIHBAUD =0x0000;
SciaRegs.SCILBAUD =0x000F;
SciaRegs.SCICCR.bit.LOOPBKENA =1;
SciaRegs.SCICTL1.all =0x0023;
}
void scia_fifo_init()
{
SciaRegs.SCIFFTX.all=0xE040;
SciaRegs.SCIFFRX.all=0x2044;
SciaRegs.SCIFFCT.all=0x0;
}