您的位置: OpenADSP社区论坛 -> Blackfin专区 -> 新手上路 -> BF51X技术支持专区 -> BF518自测历程求助
本帖共有879个阅读者
发表帖子 发表投票 回复主题
BF518自测历程求助
shaodong14(论坛新手)
shaodong14
头衔:社区公民
帮派:无帮无派
帖数:2
金钱:119
积分:3
注册时间:2011/8/24
楼主信息 | 留言 | Email | 主页 | 编辑 | 管理 | 离线
BF518自测历程求助

求助:BF518按照AUDIO自测历程无法用TWI给2603配置寄存器,示波器测TWI时钟没信号,MCOMP没置位,要等到TimeOut跑完。

void TWI_MasterMode_Write(unsigned short DeviceAddr, unsigned char *TWI_Data_Pointer, unsigned short Count, unsigned short TWI_Length)
{
int i, j, timeout;

if (*pTWI_MASTER_STAT & SDASEN)
{
  if(!ClrSclSda())
   return;
}

/* make sure no previous errors occured */
if (TWISuccess == 1)
{  

     *pTWI_FIFO_CTL = 0;         /* clear the bit manually */
  *pTWI_CONTROL = TWI_ENA | PRESCALE_VALUE;   /* PRESCALE = fsclk/10MHz */
  *pTWI_CLKDIV = ((CLKDIV_HI) << 8) | (CLKDIV_LO); /* CLKDIV = (1/SCL)/(1/10MHz) */
  *pTWI_MASTER_ADDR = DeviceAddr;      /* target address (7-bits plus the read/write bit) */

  for (i = 0; i < Count; i++)
  {
      /* # of configurations to send */
   *pTWI_XMT_DATA8 = *TWI_Data_Pointer++; /* pointer to data */
   ssync();

   *pTWI_MASTER_CTL = (TWI_Length<<6) | MEN /*| FAST*/; /* start transmission */

   timeout = 0x1000;
  
   for (j = 0; j < (TWI_Length-1); j++)
   {
       /* # of transfers before stop condition */
    while ((*pTWI_FIFO_STAT == XMTSTAT) && --timeout) /* wait to load the next sample into the TX FIFO */  // TAR37913
    {
     ssync();
    }
    if(!timeout)
     return;

    *pTWI_XMT_DATA8 = *TWI_Data_Pointer++;  /* load the next sample into the TX FIFO */
    ssync();
   }
  
   timeout = 0x1000;
  
   while (!(*pTWI_INT_STAT & MCOMP) && --timeout)   /* wait until transmission complete and MCOMP is set */
   {
    ssync();
   }
   if(!timeout)
    return;

   /* check if an error occured */
   if ((*pTWI_INT_STAT & MERR) == MERR)
   {
    *pTWI_INT_STAT |= MERR;
    TWISuccess = 0;  
   }
  
   *pTWI_INT_STAT = XMTSERV | MCOMP;    /* service TWI for next transmission */
  }
}

asm("nop;");
asm("nop;");
asm("nop;");
}



这家伙很懒,什么也没有留下!
等级:论坛新手 参考IP地址:*.*.*.*
2011/8/24 11:30:36
尊贵身份标志
andy(论坛版主)
andy
头衔:社区公民
帮派:无帮无派
帖数:2287
金钱:11132
积分:2263
注册时间:2011/6/8
1信息 | 留言 | Email | 主页 | 编辑 | 管理 | 离线

单步运行进IIC代码看看能过不,不能过的话,检查器件IIC地址是否有误,Blackfin上的IIC地址为7bit,不包含读写位,所以送地址时要“DeviceAddr>>1”,你注意下。


这家伙很懒,什么也没有留下!
等级:论坛版主 参考IP地址:*.*.*.*
2011/8/24 11:50:56
shaodong14(论坛新手)
shaodong14
头衔:社区公民
帮派:无帮无派
帖数:2
金钱:119
积分:3
注册时间:2011/8/24
2信息 | 留言 | Email | 主页 | 编辑 | 管理 | 离线

地址是按例程设置的

/* codec's TWI address, this is the upper 7 bits, the lowest bit will
be 0 for write (0x36), and 1 for read (0x37) */
#define CODEC_TWI_ADDRESS 0x1b

分步进入TWI函数时MCOMP始终不能置位

unsigned char ResetControl[] =  { 0x1e, 0x00};

unsigned char LeftLineIn[] =   { 0x00, 0x01b};
unsigned char RightLineIn[] =   { 0x02, 0x01b};
unsigned char LeftHpOut[] =   { 0x04, 0x07f};
unsigned char RightHpOut[] =   { 0x06, 0x07f};
unsigned char AnalogControl[] =  { 0x08, 0x010};
unsigned char DigitalControl[] =  { 0x0a, 0x000};
unsigned char PowerDownControl[] =  { 0x0c, 0x000};
unsigned char DigitalAudioFormat[] ={ 0x0e, 0x042};
unsigned char SamplingControl[] =  { 0x10, 0x001};

unsigned char ActiveControl[] =  { 0x12, 0x001};

int TWI_Error = 0;

TWISuccess = 0;

while (TWISuccess == 0 && TWI_Error < 100)
{
  TWISuccess = 1;
  Reset_TWI();  /* reset the TWI interface */

   TWI_MasterMode_Write( CODEC_TWI_ADDRESS, ResetControl, 1, 2);
  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, LeftLineIn, 1, 2);
  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, RightLineIn, 1, 2);
  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, LeftHpOut, 1, 2);
  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, RightHpOut, 1, 2);
  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, AnalogControl, 1, 2);
  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, DigitalControl, 1, 2);
  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, PowerDownControl, 1, 2);
  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, DigitalAudioFormat, 1, 2);
  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, SamplingControl, 1, 2);

   if(TWISuccess)
   for (j=0; j<0x1ffffff; j++) asm("nop;");

  /*** lastly activate the digital engine *******************/

  TWI_MasterMode_Write( CODEC_TWI_ADDRESS, ActiveControl, 1, 2);
  
  if(!TWISuccess)
   TWI_Error++;
}


这家伙很懒,什么也没有留下!
等级:论坛新手 参考IP地址:*.*.*.*
2011/8/24 12:34:49
尊贵身份标志
andy(论坛版主)
andy
头衔:社区公民
帮派:无帮无派
帖数:2287
金钱:11132
积分:2263
注册时间:2011/6/8
3信息 | 留言 | Email | 主页 | 编辑 | 管理 | 离线

你代码有没有分配端口功能?

这个问题比较具体,只能靠你自己去查,可以这样查:

确认硬件焊接等问题,派出硬件异常。

利用示波器的触发功能看能否抓到IIC波形,通常IIC波形就一瞬间,只能通过触发功能抓取。

检查器件地址是否为自己配置的器件,硬件上啦电阻是否正常

单步执行一次IIC写入操作能否得到ACK信号,用示波器是否能抓取该信号。

先确定这些是否正常再往下走吧



这家伙很懒,什么也没有留下!
等级:论坛版主 参考IP地址:*.*.*.*
2011/8/24 14:34:12
Powered by OpenADSP Copyright © 2010 www.Openadsp.com. All rights reserved.164659 Call, 1 Queries, Processed in 0.015625 second(s),