最近改了一个程式如下,调试时发现运行M_LowBatteryPower时,第一次可以有LED闪烁,led灯灭之后开不了机,必须断电重来。 void main(void) { u8 button_test=1; /*!<Set High speed internal clock */ CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); //16MHz /* TIM4 counter 1ms */ Tim4_Init(); //1ms counter interrupts /* ADC Ch4 & Ch3 Init */ ADCPin_Init(); __enable_interrupt(); /* LED_GPIO */ LED_Init(); /* GPIO_input */ INGPIO_Init(); POWER(OFF); t25minstop = T25MIN_STOP; while(ADCBatteryFirstOK) // power on check battery Level low power or not { LED_3(OFF); LED_4(OFF); SetUltrasound_PWM(0); // Ultrasound OFF Get_Battery_ADC(); if(Conversion_Value[0] < 2.1) { batterylow_flg = 1; //BatteryLV = 5;//2改为 //Dischargeindicator_stage = BatteryL; } if(fbtadc) if(Conversion_Value[0] > 2.1) // 1.875/20190417 ADCBatteryFirstOK = 0; batterylow_flg = 0; }; while(1) { KeyNo = GetKey(); Get_Battery_Ultrasound_ADC(); // 1ms get battery adc *20 = 20ms & 1ms get ultsound adc*20 = 20ms GetBattery_Level_Process(Run_Mode); Get_Battery_ADC(); BatteryIndicator_Process(Run_Mode,Dischargeindicator_stage); if(batterylow_flg) Run_Mode = M_LowBatteryPower;//0421 switch(Run_Mode) { case M_WaitKey: // check key = enter or 3s enter { // workingtime.Tcut_flg = disable; t1secstop = 1750; t25minstop = T25MIN_STOP; offsetcut = 0; // t10secstop = 5000; LED_3(OFF); LED_4(OFF); if(KeyNo == KEY_ENTER) Run_Mode = M_Standard; else if(KeyNo == KEY_3SENTER) Run_Mode = M_Inverse; } break; case M_Inverse: // M_Inverse mode { POWER(ON); // power latch LED_3(ON); LED_4(ON); EN_Inverse = 1; // disable no water auto stop if(t1secstop == 0 && KeyNo == NO_KEY) Run_Mode = M_Standard; } break; case M_Standard: // standard mode { while(button_test) { POWER(ON); LED_3(OFF); LED_4(ON);// power latch TIM2_PWM_Init(); //Ultrasound PWM init button_test = 0; // workingtime.Tcut_flg = enable; /* for(n=0;n<30;n++) { wt.buff1[n] = 0; wt.buff2[n] = 0; wt.buff3[n] = 0; } */ wt.ost_gap = 0; wt.ost_old = 0; wt.ost_new = 0; } if(scan_ultrasound_PWM) // ultrasound { scan_ultrasound_PWM = 0; UltSound_Scanfrequency_process(Dischargeindicator_stage); } if(KeyNo != NO_KEY) Run_Mode = M_PowerOFF; } break; case M_LowBatteryPower: { if(lowpowercut >= 5) { //SetUltrasound_PWM(0);//放在这里闪烁5次灯,只有才不喷雾 //Run_Mode = M_PowerOFF; SetUltrasound_PWM(0); } else //{ if(lowledstep == 0) // Red On { if(tLowbatteryshutter == 0) { tLowbatteryshutter = 500; //LED_1(OFF); //LED_2(OFF); LED_3(ON); LED_4(OFF); //LED_5(OFF); lowledstep = 1; } } else if(lowledstep == 1) //Red Off { if(tLowbatteryshutter == 0) { tLowbatteryshutter = 500; //LED_1(OFF); //LED_2(OFF); LED_3(OFF); LED_4(OFF); //LED_5(OFF); lowledstep = 0; lowpowercut++; } } //} } break; //////////////////////////////////////////////////////////////////////////////////////////// default: case M_PowerOFF: { // workingtime.Tcut_flg = disable; SetUltrasound_PWM(0); LED_3(OFF); LED_4(OFF); POWER(OFF); Run_Mode = M_WaitKey; button_test = 1; scan_step = 0; t25minstop = T25MIN_STOP; BatteryLV = 0; wt.adc_old = 0; wt.cut = 0; wt.tTemp = 0; wt.adc_gap = 0; wt.adc_new = 0; wt.n = 0; offsetcut = 0; EN_Inverse = 0; batterylow_flg = 0;//0421 // t10secstop= 5000;//0417 } break; |
你是如何从低功耗模式下唤醒的?看不到相关的代码啊? |
跑飞了没有 |
测试标签123
IAR FOR ARM和IAR FOR STM8无法共存,
STM8L052,液晶内部电源怎么用?
STM8S103飞线外接芯片,I2C不能得到slaveAddress应答,通讯失败。
STM8S105C6T6 UART2串口,能接收数据,不能发送数据
STM8S105K4 串口2 无奇偶校验,也能接收 偶校验的 数据
在STM8S的IAP使用中断和APP使用中断问题
STM8L151 SMBUS设计
STM8S103F复位异常
STM8L的LCD调试时不亮