最近改了一个程式如下,调试时发现运行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; |
你是如何从低功耗模式下唤醒的?看不到相关的代码啊? |
跑飞了没有 |
STMS005K6T6 如何采集内部参考电压。
stm8s003 adc中断和通道切换的问题
adc施密特触发器stm8
stm8l051f3 TSSOP20 封装,待机模式下,2天后,电流突然增加到140UA
STM8S用STVP烧录怎么加密?
如何使用ST官网例程_LIN总线通讯_STM8AF
STM8 LIN
IAR代码编辑太费劲了,想问一下有没有好的方法,试了VScode但是头文件老是报错,调了很久也没调好,想换个方法了。
想问一下各位大佬,IAR下载调试代码时出现 warning: is an illegal data sample expression IAR是什么意思啊?
STM8S标准库TIM1编码器功能不计数,请大师帮我看看