资料下载地址:SH367309中颖单片机专用动力电池保护板开发资料 原理图PCB代码
目录
1、简介
中颖BMS5-16 串 前端芯片,用于充电管理+电池保护+电量计量,有规格书,原理图,PCB, DEMO CODE全套开发资料 。
2、原理图和PCB
3、程序
cpp
#include "system.h"
#include "Uart.h"
#include "Main.h"
void main(void)
{
Initial(); //Initialize the system
while(1)
{
RSTSTAT = RSTSTAT;
if(bAFEFlg)
{
bAFEFlg = 0;
AFERdFlag();
}
if((ucResetFlag==0x12) && bUartSndAckFlg) //Software reset occurs, and ended UART communication
{
if(!bWrFlashFlg)
{
EA = 0;
ResetAFE(); //Reset IC
ResetInit(); //Reset MCU
}
}
if(bWakeupFlg) //The charger / load, keys can wake up the system
{
bWakeupFlg = 0;
WakeUpProcess(); //System to be awakened
}
if(bBleOnOffFlg) //按键长按5秒开启/关闭蓝牙
{
bBleOnOffFlg = 0;
BleOnorOff();
}
BleDisplay();
if(bCADCFlg)
{
bCADCFlg = 0;
CurProcess(); //Calculate the current value and determines the state of charge and discharge
}
if(bCalibrationFlg)
{
bCalibrationFlg = 0;
CaliProcess(); //PC calibration
}
if((bWrFlashFlg)&&(ucUpDataLimitTime == 0))
{
bWrFlashFlg = 0;
if(FlashProcess())
{
if(bUartNeedAckFlg)
{
UART_SEND_ACK;
}
}
else
{
if(bUartNeedAckFlg)
{
UART_SEND_NACK;
}
}
bUartNeedAckFlg = 0;
}
if(bLEDOpen)
{
bLEDOpen = 0;
bLEDFlg = 1;
ucLEDTimeCnt = 0;
LEDPowerOn(); //By LED displays battery capacity
}
if(bEnEEPRomBK && bE2PProcessFlg)
{
bE2PProcessFlg = 0;
E2PRomBKProcess();
}
if(bISPFlg && bUartSndAckFlg)
{
bISPFlg = 0;
ISPProcess();
}
if(bTimerFlg) //timer is 1s
{
bTimerFlg = 0;
AFECheck(); //Check AFE Register
LEDPowerOff(); //When the LED display 4s, turn off the LED
BatteryInfoManage(); //Get battery voltage and temperature information
RamCheckProcess(); //Detect the xdata block data
GaugeManage(); //Calculate the battery charge and discharge capacity
VolProcess(); //Detection of battery charge and discharge cut-off voltage
BalProcess(); //Process external voltage balance
ProtectProcess(); //Process battery abnormal state
if(bEnEEPRomBK)
{
E2PRomBKCheck(); //Detecting whether to backup EEPRom
}
ShutDownProcess(); //Detecting whether to enter a low-power
}
IntoShutDown();
}
}