ET0=1;.............................................................................................................................................................13
PWM=0;..........................................................................................................................................................13
LED1=1;..........................................................................................................................................................13
LED2=1;..........................................................................................................................................................13
}........................................................................................................................................................................13
/***********************************/.................................................................................................13
uchar adc_549(void) //AD 转换......................................................................................................................13
{........................................................................................................................................................................13
uint data_out=0;..............................................................................................................................................13
uchar i;.............................................................................................................................................................13
CS = 1;.............................................................................................................................................................13
_nop_();...........................................................................................................................................................13
CS = 0;.............................................................................................................................................................13
for (i=0; i<8; i++) /* 读取 8 位数据 */..........................................................................................................13
{.......................................................................................................................................................................13
CLK = 0;.........................................................................................................................................................13
data_out = (data_out<<1)|DOUT;...................................................................................................................13
CLK = 1;.........................................................................................................................................................13
_nop_();...........................................................................................................................................................13
}.......................................................................................................................................................................13
CLK = 0;.........................................................................................................................................................14
CS = 1;.............................................................................................................................................................14
delay(3); /* 延时 21us 以上 */.......................................................................................................................14
return(data_out);..............................................................................................................................................14
}........................................................................................................................................................................14
/**********************************/...................................................................................................14
void main(void)................................................................................................................................................14
{........................................................................................................................................................................14
init();................................................................................................................................................................14
while(1)...........................................................................................................................................................14
{.......................................................................................................................................................................14
battery_v=adc_549();......................................................................................................................................14
FuZai=1;//打开负载.......................................................................................................................................14
if(battery_v>186)//蓄电池电压大于 10V......................................................................................................14
{.......................................................................................................................................................................14
LED1=1;..........................................................................................................................................................14
LED2=0;..........................................................................................................................................................14
if(224>battery_v>204)....................................................................................................................................14
{.......................................................................................................................................................................14
TR0=1; //开启固定 PWM 充电......................................................................................................................14
if(t0==5)..........................................................................................................................................................14
{.......................................................................................................................................................................14
PWM=1;..........................................................................................................................................................14
}.......................................................................................................................................................................14