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.

请教TLC3545读取数据的问题

Other Parts Discussed in Thread: TLC3545

  在读取TLC3545时首先初始化,读取初始化后的数值和数据手册上面的一样是3FC0,但是在读取电压值(REF=5V)得时候,读取到的原始数据是跳动的整数,比如255,510,1020,2040,4080,8191,8447..等一直到16383,在两个整数之间读取不到其他数值,不知道是程序的问题还是芯片内部部分烧坏。不知道有没有TLC3545的例程给我参考,非常感谢

部分程序如下:

void init(void) {    

 unsigned char i;    

CLOCK_DIR_H;    //时钟线设置为输出    

data_DIR_L;     //数据线设置为输入    

CS_DIR_H;       //使能线设置为输出       

CS_OUT_H;    

 CLOCK_OUT_L;    

 for(i=0;i<5;i++)    

 {        

CS_OUT_L;        

 CLOCK_OUT_H;        

delay_us(1);        

CLOCK_OUT_L;        

delay_us(1);      

}    

CLOCK_OUT_H;    

 CS_OUT_H;    

delay_us(1);    

 CLOCK_OUT_L;    

   }

unsigned int TLC3545_read(void)

{  

            unsigned int i;  

           unsigned int mask=0;  

           unsigned int data=0;

           CS_OUT_L;   

  for(mask=0x8000;mask!=0;mask>>=1)  

  {         

CLOCK_OUT_H;    

delay_us(1);        

 CLOCK_OUT_L;        

 delay_us(1);        

 if(data_IN==0)          

 data&=~mask;        

 else          

 data|=mask;    

 }     

 for(i=0;i<20;i++)    

 {        

CLOCK_OUT_H;     

    delay_us(2);        

 CLOCK_OUT_L;        

 delay_us(2);      

}    

CS_OUT_H;    

delay_us(10);    

 data>>=2;    

 return data;

}