- UID
- 114293
|
void main(void)
{
InitSysCtrl();   //初始化系统
DINT;     //关中断
IER = 0x0000;
IFR = 0x0000;
InitPieCtrl();   //初始化PIE控制寄存器
InitPieVectTable();  //初始化PIE参数表
EALLOW;
GpioMuxRegs.GPFMUX.bit.SPICLKA_GPIOF2=1;
GpioMuxRegs.GPFMUX.bit.SPISIMOA_GPIOF0=1;
GpioMuxRegs.GPFMUX.bit.SPISOMIA_GPIOF1=1;
GpioMuxRegs.GPFMUX.bit.SPISTEA_GPIOF3=1;
EDIS;
    Init_Spi();    //初始化SPI ,
   while(1)
{   
  WriteDAC(0x200);
  delay(500000);
  WriteDAC(0x500);
  delay(500000);
}
}  
void WriteDAC(unsigned data)
{
if(Spi_TxReady() == 1)
  SpiaRegs.SPITXBUF = data;
//delay(5000);
//if(Spi_TxReady() == 1)
// SpiaRegs.SPITXBUF = data;
//delay(5000);
//if(Spi_TxReady()==1)
// SpiaRegs.SPITXBUF=data;
//delay(5000);
}
void delay(unsigned long t)
{ Uint16 i;
while(t-->0)
       for(i=0;i<2;i++);
我想问的是,如果函数void WriteDAC(unsigned data)为这样,
void WriteDAC(unsigned data)
{
     if(Spi_TxReady() == 1)
           SpiaRegs.SPITXBUF = data;
}
,LED只显示0X200电压的亮度,并且保持在0X200的电压(LED的亮度不变).
但如果函数void WriteDAC(unsigned data)为这样,
void WriteDAC(unsigned data)
{
     if(Spi_TxReady() == 1)
           SpiaRegs.SPITXBUF = data;
    if(Spi_TxReady() == 1)
           SpiaRegs.SPITXBUF = data;
}
LED才出现一亮(0x200电压值)一暗(0x500电压值),不知道具体是什么原因,想不通为什么,烦请高手解释解释,万分感谢!!!!
      
            注:我的DSP为TMS320F2812,DAC转换的IC为TLV5616,原理图具体请看附件,
  
     
附件: 你需要登录才可以下载或查看附件。没有帐号?注册 |
|