这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 有谁用过TLC3578吗,菜鸟求助。

共3条 1/1 1 跳转至

有谁用过TLC3578吗,菜鸟求助。

菜鸟
2010-09-01 21:11:43     打赏

向高手求助。小弟近日在使用dsPIC33F系列控制TI的AD芯片TLC3578,可是没有调出来。请问有谁用过这款芯片,在单片机程序中如何处理?能否给出TLC3578的样例代码,或者讲解一下这块芯片如何配置,如何使用。附上小弟的程序和TLC3578的手册。我确信SPI的通讯没有问题。请帮助小弟解决一下,非常感谢。


hello, everybody! Recently ,I have been getting stuck with the communication between dsPIC33FJ64 andTLC3578.I initialized and configured the TLC3578 according the TLC3578 datasheet,but it doesn'twork,always reading 0x0000.I can't know why.I am sure my SPI protocol is absolutetly right.Have anybody  used TLC3578 before ?Could you give me some sample code or explains it to me?

Thanks a lot.

Following is my source code.

/////////////////////////////////////////////////////////
/////CODE  FOR  TLC3578  ////////////////////////////////
void main()
{
// Local variables definitions
WORD tempAD;
int tt;
BYTE SS1;


//*******************Configure PLL prescaler, PLL postscaler, PLL divisor
PLLFBD=38; // M=40
CLKDIVbits.PLLPOST=0; // N1=2
CLKDIVbits.PLLPRE=0; // N2=2
// Wait for Clock switch to occur
 // Clock switching to incorporate PLL
__builtin_write_OSCCONH(0x03);  // Initiate Clock Switch to Primary
// Oscillator with PLL (NOSC=0b011)
__builtin_write_OSCCONL(0x01);  // Start clock switching
while (OSCCONbits.COSC != 0b011);
while(OSCCONbits.LOCK != 1);
 


//********OSC CLK init end**************************************
LongTimer = 0;
IO_setup();
SPI2_Init();
//Timer45_Init();

LED = 0;//LED ON;

 

//////////////////////////////////////////////////////////////
// Initialize AD module
tt = 10;
ADCS = 0;//片选AD
Nop();
SPI2BUF = 0xA000;//进入软编程模式_WRITER_CFR_MODE
while(!SPI2STATbits.SPIRBF);
SPI2STATbits.SPIROV = 0;
tempAD = SPI2BUF;
ADCS = 1;
Nop();
Nop();
ADCS = 0;
Nop();
tt = 10;
SPI2BUF = 0xAA00;      //单端输入,短采样时;00 for INT mode ,04 for EOC mode
//SPI2BUF = 0xA800;       // hardware default mode
while(!SPI2STATbits.SPIRBF);
tempAD = SPI2BUF;
SPI2STATbits.SPIROV = 0;
ADCS = 1;

//**************************************

while(1)
 {
 SADres = ReadAD(0X07);
 }
}
//************************Program main loop ends**************************


WORD ReadAD(BYTE CHx)
{
  int tick;
  WORD AD_res,tmpad;
  //tick = 10;
  //CHx = 0x7000;
  ADCS = 0;
  Nop();
  SPI2BUF = 0x7000;
  while(!SPI2STATbits.SPIRBF);
  //ADCS = 1;
  while(ADEOC);
  //tick = 10;
  //ADCS = 0;
  SPI2BUF = 0x0000;
  while(!SPI2STATbits.SPIRBF);
  AD_res = SPI2BUF;
  SPI2STATbits.SPIROV = 0;
  ADCS = 1;
  AD_res /=4;
  AD_res &= 0x3FFF;
 
  return AD_res;
}
  




关键词: 用过     TLC3578     菜鸟     求助    

院士
2010-09-01 21:28:36     打赏
2楼

发完问题就跑啊?


专家
2010-09-03 08:36:04     打赏
3楼
似乎程序有点问题的哦

共3条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]