Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 2. Thank you for your patience.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

数据转换器TLC3578

Other Parts Discussed in Thread: TLC3578, TMS320F2812

TLC3578工作模式为REPEAT SWEEP MODE, 用CS片选端驱动转换器,采样出来的结果为0,这是为什么?

代码如下:

void Inittlc3578(void)  //初始化TLC3578
{
SPI_CS_H;
SPI_CS_L;
spi_delay(1);
spi_xmit(0xA000);
spi_delay(1);
spi_xmit(0xAA61);
spi_delay(1);
}

void starttlc3578(void)   //启动3578
{
int i=0;
SPI_CS_L;
for(i=0;i<6;i++)
{
SPI_CS_H;
spi_delay(1);
SPI_CS_L;
spi_xmit(C[i]);
spi_delay(1);
}
}

  • Hi
    I've moved your post to the Precision Data Converters forum where the appropriate experts can answer your question.
    Best regards,
    Jim B
  • Hi ,

    Could you please elaborate on your questions and provide us more details?

    Thank you and best regards,

    Jose

  • Thank for your help;

    I choose the operating mode of tlc3578 is REPEAT SWEEP MODE,3/4FIFO,internatel OSC ,six channels from channel 0 to chanel 5,short sampling ,pin used as INT,and the input mode is single_ended,Sweep auto sequence select "00";

    What I want to do is that SPI transmit the data which is collected by tlc3578 to TMS320F2812,and then ,the data is transmited to the host computer by SCI.

    I meet with a problem which is all data of tlc3578' collection is zero.why?

    The program code is as follow:

    #include"DSP281x_Device.h"
    #include"DSP281x_Examples.h"
    #define SPI_CS_H CS_disconnect();
    #define SPI_CS_L CS_connect();
    interrupt void cputimer0_isr(void);
    interrupt void xint_isr(void);
    float I1[12],I2[12],I3[12],I4[12],I5[12],I6[12];
    int Im1,Im2,Im3,Im4,Im5,Im6;
    int W1,W2,W3,W4,W5,W6;
    int Ir1,Ir2,Ir3,Ir4,Ir5,Ir6;
    int Ii1,Ii2,Ii3,Ii4,Ii5,Ii6;
    int conversioncount=0;
    int I[6];
    #define Iset 10000
    int C[6]={0000,1000,2000,3000,4000,5000};
    void starttlc3578(void);
    void Inittlc3578(void);

    main()
    {
    InitSysCtrl();
    DINT;
    EALLOW;
    PieVectTable.TINT0=&cputimer0_isr;
    PieVectTable.XINT1=&xint_isr;
    EDIS;
    EALLOW;
    GpioMuxRegs.GPFMUX.all=0x003F;
    GpioMuxRegs.GPEMUX.bit.XINT1_XBIO_GPIOE0=1;
    GpioMuxRegs.GPBMUX.all=0x0000;
    GpioMuxRegs.GPBDIR.all=0xFFFF;
    EDIS;
    InitPieCtrl();
    IER=0x0000;
    IFR=0x0000;
    InitPieVectTable();
    InitCpuTimers();
    InitSpi();
    ConfigCpuTimer(&CpuTimer0,150,1667);
    StartCpuTimer0();
    PieCtrlRegs.PIEIER1.bit.INTx3=1;
    PieCtrlRegs.PIEIER1.bit.INTx4=1;
    IER|=M_INT1;
    EINT;
    ERTM;
    Inittlc3578();
    InitSci();
    starttlc3578();
    if(conversioncount==11)
    {
    int i=0;
    int tempresult;
    for(i=0;i<12;i++)
    {
    tempresult=I1[i]*12403/10000-101;
    if(tempresult>20000)
    {tempresult=20000;}
    tempresult=I2[i]*12444/10000-160;
    if(tempresult>20000)
    {tempresult=20000;}
    tempresult=I3[i]*12446/10000-163;
    if(tempresult>20000)
    {tempresult=20000;}
    tempresult=I4[i]*12447/10000-164;
    if(tempresult>20000)
    {tempresult=20000;}
    tempresult=I5[i]*12440/10000-160;
    if(tempresult>20000)
    {tempresult=20000;}
    tempresult=I6[i]*12434/10000-160;
    if(tempresult>20000)
    {tempresult=20000;}
    }
    Ir1=(I1[0]-I1[6]+0.866*(I1[1]+I1[11]-I1[5]-I1[7])+0.5*(I1[2]+I1[10]-I1[4]-I1[8]))/6;
    Ii1=(I1[3]-I1[9]+0.866*(I1[2]+I1[4]-I1[8]-I1[10])+0.5*(I1[1]+I1[5]-I1[7]-I1[11]))/(-6);
    Im1=sqrt(Ir1^2+Ii1^2);
    W1=atan(Ir1/Ii1);
    Ir2=(I2[0]-I2[6]+0.866*(I2[1]+I2[11]-I2[5]-I2[7])+0.5*(I2[2]+I2[10]-I2[4]-I2[8]))/6;
    Ii2=(I2[3]-I2[9]+0.866*(I2[2]+I2[4]-I2[8]-I2[10])+0.5*(I2[1]+I2[5]-I2[7]-I2[11]))/(-6);
    Im2=sqrt(Ir1^2+Ii1^2);
    W2=atan(Ir2/Ii2);
    Ir3=(I3[0]-I3[6]+0.866*(I3[1]+I3[11]-I3[5]-I3[7])+0.5*(I3[2]+I3[10]-I3[4]-I3[8]))/6;
    Ii3=(I3[3]-I3[9]+0.866*(I3[2]+I3[4]-I3[8]-I3[10])+0.5*(I3[1]+I3[5]-I3[7]-I3[11]))/(-6);
    Im3=sqrt(Ir3^2+Ii3^2);
    W3=atan(Ir3/Ii3);
    Ir4=(I4[0]-I4[6]+0.866*(I4[1]+I4[11]-I4[5]-I4[7])+0.5*(I4[2]+I4[10]-I4[4]-I4[8]))/6;
    Ii4=(I4[3]-I4[9]+0.866*(I4[2]+I4[4]-I4[8]-I4[10])+0.5*(I4[1]+I4[5]-I4[7]-I4[11]))/(-6);
    Im4=sqrt(Ir4^2+Ii4^2);
    W4=atan(Ir4/Ii4);
    Ir5=(I5[0]-I5[6]+0.866*(I5[1]+I5[11]-I5[5]-I5[7])+0.5*(I5[2]+I5[10]-I5[4]-I5[8]))/6;
    Ii5=(I5[3]-I5[9]+0.866*(I5[2]+I5[4]-I5[8]-I5[10])+0.5*(I5[1]+I5[5]-I5[7]-I5[11]))/(-6);
    Im5=sqrt(Ir5^2+Ii5^2);
    W1=atan(Ir5/Ii5);
    Ir6=(I6[0]-I6[6]+0.866*(I6[1]+I6[11]-I6[5]-I6[7])+0.5*(I6[2]+I6[10]-I6[4]-I6[8]))/6;
    Ii6=(I6[3]-I6[9]+0.866*(I6[2]+I6[4]-I6[8]-I6[10])+0.5*(I6[1]+I6[5]-I6[7]-I6[11]))/(-6);
    Im6=sqrt(Ir6^2+Ii6^2);
    W6=atan(Ir6/Ii6);
    if(Im1+Im2>Iset)
    {
    GpioDataRegs.GPBSET.bit.GPIOB7=1;
    conversioncount=0;
    }
    else if(Im3+Im4>Iset)
    {
    GpioDataRegs.GPBSET.bit.GPIOB8=1;
    conversioncount=0;
    }
    else if(Im5+Im6>Iset)
    {
    GpioDataRegs.GPBSET.bit.GPIOB9=1;
    conversioncount=0;
    }
    }

    for(;;){}

    }


    void spi_xmit(int a)
    {
    SpiaRegs.SPITXBUF=a;

    }


    void scia_xmit(int a)
    {
    SciaRegs.SCITXBUF=(a&0xffff);
    while(SciaRegs.SCICTL2.bit.TXRDY!=1){};
    }


    void spi_delay(int Num)
    {
    while(Num)
    {
    int i = 2; //这里可以优化速度
    Num--;
    while(i)
    {
    i--;
    }
    }
    }

    void CS_disconnect(void)
    {
    EALLOW;
    GpioDataRegs.GPBSET.bit.GPIOB3=1;
    EDIS;
    }

    void CS_connect(void)
    {
    EALLOW;
    GpioDataRegs.GPBCLEAR.bit.GPIOB3=0;
    EDIS;
    }

    void Inittlc3578(void)
    {
    SPI_CS_H;
    SPI_CS_L;
    spi_delay(1);
    spi_xmit(0xA000);
    spi_delay(1);
    spi_xmit(0xAA61);
    spi_delay(1);
    }

    void starttlc3578(void)
    {
    int i=0;
    SPI_CS_L;
    for(i=0;i<6;i++)
    {
    SPI_CS_H;
    spi_delay(1);
    SPI_CS_L;
    spi_xmit(C[i]);
    spi_delay(1);
    }
    }


    interrupt void xint_isr(void)
    {
    int conversioncount=0;
    int i,j=0;
    for(i=0;i<6;i++)
    {
    SPI_CS_H;
    spi_delay(1);
    SPI_CS_L;
    I[i]=(SpiaRegs.SPIRXBUF>>=2);
    scia_xmit(I[i]);
    spi_delay(1);
    }
    for(j=0;j<12;j++)
    {
    I1[j]=I[0];I2[j]=I[1];I3[j]=I[2];
    I4[j]=I[3];I5[j]=I[4];I6[j]=I[5];
    }
    PieCtrlRegs.PIEACK.all=PIEACK_GROUP1;
    conversioncount++;
    return;
    }

    interrupt void cputimer0_isr(void)
    {
    int i=0;
    for(i=0;i<6;i++)
    {
    SPI_CS_H;
    spi_delay(1);
    SPI_CS_L;
    spi_xmit(C[i]);
    spi_delay(1);
    }
    PieCtrlRegs.PIEACK.all=PIEACK_GROUP1;
    return;
    }

  • Hi user4687868,

    You are very welcome! I am glad I am able to help.

    Your code seems correct so I do not know where exactly the problem lies. Could you please capture oscilloscope or logic analyzer plots of the signals you are passing onto the TLC3578 in pins 1, 2, 3, 4, and 5? While you do that, could you please connect pins 9, 10, 11, 12, 13, 14, 15, and 16 to ground?

    Best regards,

    Jose