#include
"DSP28x_Project.h"
// Device Headerfile and Examples Include File #define LSPCLK_FREQ CPU_FREQ/4 #define SCI_PRD
(LSPCLK_FREQ/(SCI_FREQ*8))-1 // Prototype statements for functions found within this file. interrupt void sciaTxFifoIsr(void); interrupt void sciaRxFifoIsr(void); interrupt void scibTxFifoIsr(void); interrupt void scibRxFifoIsr(void); void scia_fifo_init(void); void scib_fifo_init(void); Uint16 sdataA[8];
// Send data for SCI-A Uint16 rdataA[8];
// Received data for SCI-A Uint16 rdata_pointA; // Used for checking the received data
EALLOW;
// This is needed to write to EALLOW protected registers
PieVectTable.SCIRXINTA = &sciaRxFifoIsr;
PieVectTable.SCITXINTA = &sciaTxFifoIsr;
EDIS;
// This is needed to disable write to EALLOW protected registers
rdata_pointA = sdataA[0];
// Enable interrupts required for this example
PieCtrlRegs.PIECTRL.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 = 0x100; // Enable CPU INT
asm("
ESTOP0"); // Test failed!! Stop!
interrupt void sciaTxFifoIsr(void)
SciaRegs.SCITXBUF=sdataA;
// Send data
for(i=0; i< 2; i++)
//Increment send data for next cycle
sdataA = (sdataA+1) & 0x00FF;
SciaRegs.SCIFFTX.bit.TXFFINTCLR=1;
// Clear SCI Interrupt flag
PieCtrlRegs.PIEACK.all|=0x100;
// Issue PIE ACK
interrupt void sciaRxFifoIsr(void)
rdataA=SciaRegs.SCIRXBUF.all;
// Read data
for(i=0;i<2;i++)
// Check received data
if(rdataA != ( (rdata_pointA+i) & 0x00FF) ) error();
rdata_pointA = (rdata_pointA+1) & 0x00FF;
SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1;
// Clear Overflow flag
SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;
// Clear Interrupt flag
PieCtrlRegs.PIEACK.all|=0x100;
// Issue PIE ack
SciaRegs.SCICCR.all =0x0007;
// 1 stop bit,
No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
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 = 0x0000;
SciaRegs.SCILBAUD = SCI_PRD;
SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
SciaRegs.SCIFFTX.all=0xC022;
SciaRegs.SCIFFRX.all=0x0022;
SciaRegs.SCIFFCT.all=0x00;
SciaRegs.SCICTL1.all =0x0023;
// Relinquish SCI from Reset
SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
上述程序功能是在28035中运行,发送sdataA[0],sdataA[1]的数据,接收数据存放在rdataA[0],rdataA[1]中,运行没问题, 我将其改成发送sdataA[0]~sdataA[7],并将接收数据存放在rdataA[0]~rdataA[7]中,并修改以下代码: SciaRegs.SCIFFTX.all=0xC028; SciaRegs.SCIFFRX.all=0x0028; 运行时就出错了。但是我用同样的更改在28335中运行,又是正常,请教是什么原因。如何解决才能在28035中运行正常。 |