1、简介
中颖BMS5-16 串 前端芯片,用于充电管理+电池保护+电量计量,有规格书,原理图,PCB, DEMO CODE全套开发资料 。
2、原理图和PCB
3、程序
#include "system.h"
#include "Uart.h"
#include "Main.h"
void main(void)
{
Initial(); //Initialize the system
while(1)
{
RSTSTAT = RSTSTAT;
if(bAFE**)
{
bAFE** = 0;
AFERdFlag();
}
if((ucResetFlag==0x12) && bUartSndAck**) //Software reset occurs, and ended UART communication
{
if(!bWrFlash**)
{
EA = 0;
ResetAFE(); //Reset IC
ResetInit(); //Reset MCU
}
}
if(bWakeup**) //The charger / load, keys can wake up the system
{
bWakeup** = 0;
WakeUpProcess(); //System to be awakened
}
if(bBleOnOff**) //按键长按5秒开启/关闭蓝牙
{
bBleOnOff** = 0;
BleOnorOff();
}
BleDisplay();
if(bCADC**)
{
bCADC** = 0;
CurProcess(); //Calculate the current value and determines the state of charge and discharge
}
if(bCalibration**)
{
bCalibration** = 0;
CaliProcess(); //PC calibration
}
if((bWrFlash**)&&(ucUpDataLimitTime == 0))
{
bWrFlash** = 0;
if(FlashProcess())
{
if(bUartNeedAck**)
{
UART_SEND_ACK;
}
}
else
{
if(bUartNeedAck**)
{
UART_SEND_NACK;
}
}
bUartNeedAck** = 0;
}
if(bLEDOpen)
{
bLEDOpen = 0;
bLED** = 1;
ucLEDTimeCnt = 0;
LEDPowerOn(); //By LED displays battery capacity
}
if(bEnEEPRomBK && bE2PProcess**)
{
bE2PProcess** = 0;
E2PRomBKProcess();
}
if(bISP** && bUartSndAck**)
{
bISP** = 0;
ISPProcess();
}
if(bTimer**) //timer is 1s
{
bTimer** = 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();
}
}
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_35654286/article/details/145109727
|