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

程序功能:

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] != '\0')
    {
        scic_xmit(msg[i]);
        i++;
    }
}

// Initalize the SCI FIFO
void scic_fifo_init()
{
//    ScicRegs.SCIFFTX.all=0xE040;
//    ScicRegs.SCIFFRX.all=0x204f;   //0010 0000 0100 1111
//    ScicRegs.SCIFFCT.all=0x0;
	ScibRegs.SCIFFTX.all=0x8000;
}






//===========================================================================
// No more.
//===========================================================================

 

  • 4
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值