使用BQ76PL455EVM和TMS57004 LaunchPad 开发板,接入16节串联电池组。只有在读取电压的那一行程序处设置断点,程序运行至断点才能读取到正确的电压。但是如果不设置断点,让程序运行起来,就会读取到全部相同的错误的电压。帖子的最后附上我程序的压缩包
以下是断点处读取的电压
以下是错误的数据:
最后附上我的程序:
#include "system.h"
#include "gio.h"
#include "sci.h"
#include "rti.h"
#include "sys_vim.h"
#include "swi_util.h"
int RTI_TIMEOUT = 0;
BYTE bFrame[39];
/* USER CODE END */
* @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 END */
void delay_loop();
void main(void)
{
/* USER CODE BEGIN (3) */
systemInit();
gioInit();
sciInit();
sciSetBaudrate(scilinREG, BAUDRATE);
rtiInit();
vimInit();
int nSent, nRead, nTopFound = 0;
int nDev_ID, nGrp_ID;
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();
}
long x, y;
for (y = 0; y < 10; y++)
for (x = 0; x < 50000; x++) {
}
}
/* USER CODE END */