#include "inc/DSP28_Device.h"
#include "inc/DSP28_GlobalPrototypes.h"
#define uchar unsigned char
#define uint unsigned int
unsigned int *Led = (unsigned int *)0x4100;
uchar rec;
interrupt void sci_rx(void)
{
rec = SciaRegs.SCIRXBUF.all;
rec=rec & 0xff;
SciaRegs.SCITXBUF =rec ;
while(SciaRegs.SCICTL2.bit.TXRDY !=1);回传收到的信息
*Led= rec;
PieCtrl.PIEACK.all |= 0x100;
SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;
SciaRegs.SCIFFRX.bit.RXOVF_CLR=1;清除各个标志位
//SciaRegs.SCIFFRX.bit.RXFFOVF=1;
}
interrupt void sci_tx(void)
{
PieCtrl.PIEACK.all |= 0x100;
SciaRegs.SCIFFTX.bit.TXINTCLR=1;
//SciaRegs.SCIFFRX.bit.RXFFOVF=1;
}
void init_sci()
{
SciaRegs.SCICCR.all = 0x07;
SciaRegs.SCICTL1.all=0x03;//
SciaRegs.SCIHBAUD=0x00;//
SciaRegs.SCILBAUD=0xf3;//波特率设置为19200
SciaRegs.SCICTL2.all=0x03;//
SciaRegs.SCIFFRX.all=0x21;//
SciaRegs.SCIFFTX.all=0xe020;设置fftx
SciaRegs.SCIFFCT.all=0x0000;
SciaRegs.SCIFFRX.bit.RXFIFORESET=1;
SciaRegs.SCICTL1.bit.SWRESET=1;复位结束
EALLOW;
PieVectTable.RXAINT=&sci_rx;
PieVectTable.TXAINT=&sci_tx;
GpioMuxRegs.GPFMUX.bit.SCIRXDA_GPIOF5=1;
GpioMuxRegs.GPFMUX.bit.SCITXDA_GPIOF4=1;
GpioMuxRegs.GPFDIR.bit.GPIOF4=1;
GpioMuxRegs.GPFDIR.bit.GPIOF5=0;
EDIS;
}
void main(void )
{
InitSysCtrl();
DINT;
*Led= 0x55;
InitPieCtrl();
InitPieVectTable();
init_sci();
PieCtrl.PIEIER9.bit.INTx1=1;
PieCtrl.PIEIER9.bit.INTx2=1;
IER |= M_INT9;
EINT;
ERTM; // Enable Global realtime interrupt DBGM
SciaRegs.SCITXBUF =0x01 ;
while(SciaRegs.SCICTL2.bit.TXRDY !=1);
SciaRegs.SCITXBUF =0x03 ;
while(SciaRegs.SCICTL2.bit.TXRDY !=1);
SciaRegs.SCITXBUF =0x05 ;
while(SciaRegs.SCICTL2.bit.TXRDY !=1);
while(1);
}
newsci.zip
(99.66 KB)
|