微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 硬件电路设计 > TI电源管理交流 > 如何使用ManufacturerBlockAccess() 读bq40Z50-R1的dafaflash

如何使用ManufacturerBlockAccess() 读bq40Z50-R1的dafaflash

时间:10-02 整理:3721RD 点击:

这是芯片手册里的内容,但是按照此方法,读取失败

To read the DF, send an SMBus block write to the ManufacturerBlockAccess(), followed by the starting
address, then send an SMBus block read to the ManufacturerBlockAccess(). The return data contains the
starting address followed by 32 bytes of DF data in Little Endian.
117 SLUUBC1B–July 2015–Revised December 2015 SBS Commands
Submit Documentation Feedback
Copyright © 2015, Texas Instruments Incorporated
0x00 ManufacturerAccess() and 0x44 ManufacturerBlockAccess() www.ti.com
Read from DF example:
Taking the same assuming from the read DF example, to read DF,
a. Send SMBus write block with command 0x44, block = 0x00 + 0x40
b. Send SMBus read block with command 0x44
The returned block = a starting address + 32 bytes of DF data
= 0x00 + 0x40 + data1_LowByte + data1_HighByte + data2_LowByte + data2_HighByte....
data32_LowByte + data32_HighByte
The gauge supports an auto-increment on the address during a DF read. This greatly reduces the time
required to read out the entire DF. Continue with the read from the DF example. If another SMBus read
block is sent with command 0x44, the gauge returns another 32 bytes of DF data, starting with address
0x4020.
13.1.63 ManufacturerAccess() 0xF0

请把你发送的命令时序列出来,看看问题出在哪里。

问题已经解决了,主要是

SMBus block write 操作,在发送完命令后,要发送长度字节,而之前没有发送字节长度。

你好,请问可以把SMBus block write的代码贴一下吗?谢谢!

关于 SMBus block write 和 SMBus block read   请在百度里搜索   "SMBus协议总结(翻译)",这边文章讲的很好。

下面是相关代码

uint16_t ManufacturerBlockAccess_Read_U5(uint16_t command)
{
    TxData[0] = 0x44;
    TxData[1] = 2;
    TxData[2] = command & 0xff;
    TxData[3] = (command >> 8) & 0xff;
    MSP430_SWI2CMST_writeBlock(I2CSLAVEADDR, 4, 0, TxData);
    MSP430_bq40Z50_read(0x44, 5);
    __delay_cycles(16000);
    return (uint16_t)(RxData[3] + (RxData[4] << 8));
}

void MSP430_SWI2CMST_writeBlock(unsigned char SlaveAddress,
                                unsigned int numBytes, unsigned char multi,
                                void* TxData)
{        
  unsigned int  i;
  unsigned char *temp;
   
  temp = (unsigned char *)TxData;           // Initialize array pointer
  MSP430_SWI2CMST_start();                  // Send Start condition
  MSP430_SWI2CMST_txByte((SlaveAddress << 1) & ~BIT0); // [ADDR] + R/W bit = 0
  for (i = 0; i < numBytes; i++)
  {
    MSP430_SWI2CMST_txByte(*(temp));        // Send data and ack
    temp++;                                 // Increment pointer to next element
  }
  if (multi == 0)                           // Need STOP condition?
  {
    MSP430_SWI2CMST_stop();                 // Yes, send STOP condition
  }
  I2CDELAY;                                 // Quick delay
}

我刚刚接触这个,还有一些不理解的地方,请问可以通过QQ请教吗?

我的QQ是2537680692,麻烦加下我,可以吗?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top