TI中文支持网
TI专业的中文技术问题搜集分享网站

c2000launchpad学习之SCI查询方式自测程序

有哪位知道加入CDC功能后整个程序就死掉了不运行了是为什么

#include"DSP28x_Project.h"
void gpiosetup(void);
void scisetup(void);
/////////////////////////
void main(void)
{
  uint16_t count=0x0000;
  uint16_t rdata = 0;
  uint16_t sdata = 0;
  InitSysCtrl();
  DINT;//关中断
  IER = 0x0000;
  IFR = 0x0000;
  //初始化PIE
  InitPieCtrl();
  //初始化PIE中断向量
  InitPieVectTable();
  ///////////////////
  gpiosetup();
  scisetup();
  while(1)
  {
   sdata = count;
   SciaRegs.SCITXBUF = sdata;
   while(SciaRegs.SCIFFRX.bit.RXFFST !=1){}
   rdata = SciaRegs.SCIRXBUF.bit.RXDT;// SciaRegs.SCIRXBUF.all
   if(rdata != sdata)  GpioDataRegs.GPACLEAR.bit.GPIO3 = 1 ;
   else              GpioDataRegs.GPASET.bit.GPIO3 = 1 ;
   if(count%2)       GpioDataRegs.GPACLEAR.bit.GPIO2 = 1 ;
   else              GpioDataRegs.GPASET.bit.GPIO2 = 1 ;
      DELAY_US(500000);
      if(++count>250) count=0;
  }
}
void gpiosetup(void)
{
 EALLOW;//去保护
 ///功能选择
 //GPIO通用引脚
 GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0;
 GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0;
 //SCI模式引脚
 GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1;
 GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1;
    ///////输出
 GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;
 GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;
 //SCI输入
 GpioCtrlRegs.GPADIR.bit.GPIO28 = 0;//RXD
 GpioCtrlRegs.GPADIR.bit.GPIO29 = 1;//TXD
 //输入校验周期QUALPRD2=0默认为0
 //输入校验次数为异步输入
 GpioCtrlRegs.GPAQSEL2.bit.GPIO28=3;
 //上拉电阻使能
 GpioCtrlRegs.GPAPUD.bit.GPIO2 =1;
 GpioCtrlRegs.GPAPUD.bit.GPIO3 =1;
 //
 GpioCtrlRegs.GPAPUD.bit.GPIO28 =1;
 GpioCtrlRegs.GPAPUD.bit.GPIO29 =0;
 EDIS;//写保护
}
void scisetup(void)
{
  //soft reset=0 ,disable receive error interrupt,no transmit feature,disable sleep mode,but enable sci transmitter and receiver
   SciaRegs.SCICTL1.all = 0x03;
  //2stop bits ,disable eve/odd parity ,enable loopback, idle mode normal rs232 communications,8bit data
  SciaRegs.SCICCR.all = 0x17;
  //15M/(194+1)/8 = 9615 bps
  SciaRegs.SCILBAUD = 0xc2;
  SciaRegs.SCIHBAUD = 0x00;
  //setup  transmit fifo
  //SCI Reset,enable SCI FIFO,clear TXFIFO interrupt flag,do not match ,default set value equal to 0
  SciaRegs.SCIFFTX.all = 0x4040;
  //setup receiver fifo
  //clear RXFFOVF,clear RXFFINT flag,do not match RXFIFO ,set value equal to 4
  SciaRegs.SCIFFRX.all = 0x4044;
  //clear ABD flag ,disable CDC ,delay 0
  SciaRegs.SCIFFCT.all = 0x4000;//为什么使能CDC后整个程序就停止工作了好像SCI外设不受支配了,gpio2也不闪烁了
//exit reset sci mode
  SciaRegs.SCICTL1.bit.SWRESET = 1;
  //enable txfifo rxfifo
  SciaRegs.SCIFFTX.bit.TXFIFOXRESET = 1;
  SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;
  //enable RX or TX working
  SciaRegs.SCIFFTX.bit.SCIRST = 1;
}

赞(0)
未经允许不得转载:TI中文支持网 » c2000launchpad学习之SCI查询方式自测程序
分享到: 更多 (0)