#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
// Prototype statements for functions found within this file.
void scib_echoback_init(void);
void scib_fifo_init(void);
void scib_xmit(int a);
void scib_msg(char *msg);
interrupt void uartbuf(void);
// Global counts used in this example
Uint16 LoopCount;
Uint16 ErrorCount;
Uint16 num3=0;
Uint16 num4=0;
Uint16 RX_data;
Uint16 star,startpll;//启动信号,切锁相环信号
Uint16 cc1;
Uint16 dd;
Uint16 ee,AA,BB,CC,DD,EE,FF;
void main(void)
{
InitSysCtrl();
InitScibGpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
// MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
// InitFlash();
scib_fifo_init(); // Initialize the SCI FIFO
scib_echoback_init(); // Initalize SCI for echoback
InitCpuTimers();
EALLOW;
PieVectTable.SCIRXINTB = &uartbuf;
EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE=1;
PieCtrlRegs.PIEIER9.bit.INTx3=1;
IER|=M_INT9;
EINT;
ERTM;
num3=0;
AA =0;
CC =0;
DD =0;
EE =0;
star=0xf1;
startpll=0x00;
for(;;)
{
//while(AA ==0) {
scib_xmit(star);
scib_xmit(startpll);//}
CC=ScicRegs.SCIRXEMU;
DD=ScicRegs.SCIRXBUF.all;
while(ScicRegs.SCIFFRX.bit.RXFFST !=0)
{
FF=ScicRegs.SCIRXBUF.all;
CC=ScicRegs.SCIRXEMU;
DD=ScicRegs.SCIRXBUF.bit.SCIFFFE;
DD=ScicRegs.SCIFFRX.bit.RXFFOVF;
}
}
}
interrupt void uartbuf(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
ScicRegs.SCIFFTX.bit.TXFFINTCLR=1;
DD=ScicRegs.SCIRXBUF.all;
}
// Test 1,SCIA DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void scib_echoback_init()
{
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function
ScibRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScibRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
ScibRegs.SCICTL2.all =0x0003;
ScibRegs.SCICTL2.bit.TXINTENA = 1;
ScibRegs.SCICTL2.bit.RXBKINTENA =1;
// ScibRegs.SCICTL1.bit.RXENA=1;
//ScibRegs.SCIRXST.bit.RXWAKE=1;
#if (CPU_FRQ_150MHZ)
ScibRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 37.5MHz.
ScibRegs.SCILBAUD =0x00E7;
#endif
#if (CPU_FRQ_100MHZ)
ScibRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 20MHz.
ScibRegs.SCILBAUD =0x0044;
#endif
ScibRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}
// Transmit a character from the SCI
void scib_xmit(int a)
{
// while (ScibRegs.SCICTL2.bit.TXRDY == 0) {}
if (ScicRegs.SCIFFTX.bit.TXFFST ==0)
{ ScibRegs.SCITXBUF=a;}
}
void scib_msg(char * msg)
{
int i;
i = 0;
while(msg[i] != '\0')
{
scib_xmit(msg[i]);
i++;
}
}
// Initalize the SCI FIFO
/* void scib_fifo_init()
{
ScibRegs.SCIFFTX.all=0x8000;
}*/
void scib_fifo_init()
{
ScicRegs.SCIFFTX.all=0xE040;
// ScicRegs.SCIFFRX.all=0x204F;
ScicRegs.SCIFFRX.all=0x2068;
// ScicRegs.SCIFFRX.bit.RXFIFORESET=1;
ScicRegs.SCIFFCT.all=0x0000;
Green Deng:
回复 user6448629:
不客气