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.

BQ76PL455电压检测的问题

使用BQ76PL455EVM和TMS57004 LaunchPad 开发板,接入16节串联电池组。只有在读取电压的那一行程序处设置断点,程序运行至断点才能读取到正确的电压。但是如果不设置断点,让程序运行起来,就会读取到全部相同的错误的电压。帖子的最后附上我程序的压缩包

以下是断点处读取的电压

以下是错误的数据:

最后附上我的程序:

/* Include Files */
#include "sys_common.h"
#include "system.h"
/* USER CODE BEGIN (1) */
#include "gio.h"
#include "sci.h"
#include "rti.h"
#include "sys_vim.h"
#include "swi_util.h"
#include "pl455.h"
int UART_RX_RDY = 0;
int RTI_TIMEOUT = 0;
BYTE  bFrame[39];
/* USER CODE END */
/** @fn void main(void)
*   @brief Application main function
*   @note This function is empty by default.
*
*   This function is called after startup.
*   The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
/* USER CODE END */
void delay_loop();
void main(void)
{
/* USER CODE BEGIN (3) */
 systemInit();
 gioInit();
 sciInit();
 sciSetBaudrate(scilinREG, BAUDRATE);
 rtiInit();
 vimInit();
 _enable_IRQ();
 WakePL455();
 CommClear();
 CommReset();
 // initialize local variables
 int nSent, nRead, nTopFound = 0;
 int nDev_ID, nGrp_ID;
 uint32  wTemp = 0;

 nSent = WriteReg(0, 13, 0x10, 1, FRMWRT_ALL_NR); // 选中16节电池
 nSent = WriteReg(0, 3, 0xFFFF00C0, 4, FRMWRT_ALL_NR);
 while(1)
 {
   nDev_ID = 0;
   nSent = WriteReg(nDev_ID, 2, 0x00, 1, FRMWRT_SGL_R); // send read sampled values command
   nSent = WaitRespFrame(bFrame, 39, 0);// 24 bytes data + packet header + CRC, 0ms timeout
   gioToggleBit(gioPORTA, 2);  //此处设置断点
   delayms(500);
//   delay_loop();
 }
/* USER CODE END */
}
void delay_loop() {
 long x, y;
 for (y = 0; y < 10; y++)
  for (x = 0; x < 50000; x++) {
  }
}
/* USER CODE BEGIN (4) */
/* USER CODE END */
bq76PL455A-Q1 Example Code.rar
  • 把while循环的指令改成

     nSent = WriteReg(nDev_ID, 2, 0x00, 1, FRMWRT_SGL_NR); // send sample and store command

    delayms(6);

     nSent = WriteReg(nDev_ID, 2, 0x20, 1, FRMWRT_SGL_R); // send read sampled values command

     nSent = WaitRespFrame(bFrame, 39, 0);// 24 bytes data + packet header + CRC, 0ms timeout

  • 我把While循環裏面改了,結果還是一樣的,讀到的一直是D0BA,這是爲什麽?

    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    /* Include Files */
    #include "sys_common.h"
    #include "system.h"
    /* USER CODE BEGIN (1) */
    #include "gio.h"
    #include "sci.h"
    #include "rti.h"
    #include "sys_vim.h"
    #include "swi_util.h"
    #include "pl455.h"
    int UART_RX_RDY = 0;
    int RTI_TIMEOUT = 0;
    BYTE  bFrame[39];
    /* USER CODE END */
    /** @fn void main(void)
    *   @brief Application main function
    *   @note This function is empty by default.
    *
    *   This function is called after startup.
    *   The user can use this function to implement the application.
    */
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    void main(void)
    {
    /* USER CODE BEGIN (3) */
     systemInit();
     gioInit();
     sciInit();
     sciSetBaudrate(scilinREG, BAUDRATE);
     rtiInit();
     vimInit();
     _enable_IRQ();
     WakePL455();
     CommClear();
     CommReset();
     // initialize local variables
     int nSent, nRead, nTopFound = 0;
     int nDev_ID, nGrp_ID;
     sciSetBaudrate(scilinREG, BAUDRATE);
     uint32  wTemp = 0;

     nSent = WriteReg(0, 13, 0x10, 1, FRMWRT_ALL_NR); // set number of cells to 16
     nSent = WriteReg(0, 3, 0xFFFF00C0, 4, FRMWRT_ALL_NR);

    while(1)
     {
       nDev_ID = 0;
    //   nSent = WriteReg(nDev_ID, 2, 0x00, 1, FRMWRT_SGL_R); // send read sampled values command
    //   nSent = WaitRespFrame(bFrame, 39, 0);// 24 bytes data + packet header + CRC, 0ms timeout
    //   gioToggleBit(gioPORTA, 2);
    //   delayms(500);
       nSent = WriteReg(nDev_ID, 2, 0x00, 1, FRMWRT_SGL_NR); // send sample and store command
       delayms(6);
       nSent = WriteReg(nDev_ID, 2, 0x20, 1, FRMWRT_SGL_R); // send read sampled values command
       nSent = WaitRespFrame(bFrame, 39, 0);// 24 bytes data + packet header + CRC, 0ms timeout
       delayms(6);
    }
    /* USER CODE END */
    }
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
  • 我將While循環裏的程序替換成您提供的程序后,仍然只能在程序跑起來后讀取到完全相同的D0BA的值,只有設置斷點才能讀取到正常的電壓值,請問您能再幫我解答一下嗎?

  • 已找到问题所在,是CCS软件本身的问题,发出的数据没有错。

  • 我也在做这方面东西,可以一起讨论一下么 大哥,我qq595658552