打印

DSP2812入学习进程(8)串口中断的实现

[复制链接]
1742|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
梅花望青竹|  楼主 | 2012-4-11 10:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#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)

相关帖子

沙发
jayy| | 2012-4-11 18:59 | 只看该作者
下载了

使用特权

评论回复
板凳
jayy| | 2012-4-11 19:00 | 只看该作者
占个沙发

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

98

主题

2589

帖子

7

粉丝