DSP

F28335 SCI中断程序(不启用FIFO)

2019-07-13 11:44发布

程序功能: 1 串口发送接受的文本 2 串口中断配置完成 在这推荐一个 ADC+SCI+TIMER0的文章。https://blog.csdn.net/vanau/article/details/51881982 #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 scic_echoback_init(void); void scic_fifo_init(void); void scic_xmit(Uint16 a); void scic_msg(char *msg); void interrupt ISR_RXD(void); Uint16 led = 0; Uint16 led1 = 0; Uint16 count = 0; void main(void) { Uint16 ReceivedChar; char *msg; InitSysCtrl(); InitScicGpio(); DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); EALLOW; PieVectTable.SCIRXINTC=&ISR_RXD; EDIS; IER|=M_INT8; PieCtrlRegs.PIEIER8.bit.INTx5=1; EINT; ERTM; scic_fifo_init(); scic_echoback_init(); for(;;) { if(ScicRegs.SCIRXST.bit.RXRDY== 0) { led++; if(led==100) {led=0;} } else { led1++; ReceivedChar = ScicRegs.SCIRXBUF.all; scic_xmit(ReceivedChar); } } } void interrupt ISR_RXD(void) { count++; PieCtrlRegs.PIEACK.all = PIEACK_GROUP8; } void scic_echoback_init() { // Note: Clocks were turned on to the SCIA peripheral // in the InitSysCtrl() function ScicRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback // No parity,8 char bits, // async mode, idle-line protocol ScicRegs.SCICTL1.all =0x0003; // enable TX, RX, internal ScibLK, // Disable RX ERR, SLEEP, TXWAKE ScicRegs.SCICTL2.all =0x0003; ScicRegs.SCICTL2.bit.TXINTENA = 1; ScicRegs.SCICTL2.bit.RXBKINTENA =1; #if (CPU_FRQ_150MHZ) ScicRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 37.5MHz. ScicRegs.SCILBAUD =0x00E7; #endif #if (CPU_FRQ_100MHZ) ScicRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 20MHz. ScicRegs.SCILBAUD =0x0044; #endif ScicRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset } void scic_xmit(Uint16 a) { //while (ScicRegs.SCIFFTX.bit.TXFFST != 0) {} //当接受FIFO内无数据,才将a赋给发送寄存器 while (ScicRegs.SCICTL2.bit.TXRDY == 0) {} ScicRegs.SCITXBUF=a; } void scic_msg(char * msg) { int i; i = 0; while(msg[i] != '