stm32待机模式的电流怎么设置

Connor 火币网下载官方app 2023-01-06 289 0

前提.standby模式只能有跑给呢三rtc看门狗和外部中断来唤醒你需要20s后用rtc唤醒deepbit,所以务必把看门狗关闭(standby看门狗还是工作的,否则狗到时间会唤醒MCU)给你写代码参考/***@briefMainprogram.*@paramNone*@retval:None*/intmain(void){/*SystemClocksConfiguration*//*KeepthedefaultconfigurationHSI8MHz*//*GPIOconfiguration*/GPIO_Configuration();/*TurnonledconnectedtoPC.01*/GPIO_SetBits(GPIOC,GPIO_Pin_1);/*EnablePWRandBKPclock*/RCC_APB1Periph座手全些ClockCmd(RCC_APB1Perip进微万医切副弦请宜发心h_PWR|RCC情独独种_APB1Periph_BKP,ENABLE);/*AllowaccesstoBKP密府风真贵Domain*/PWR_BackupAccessCmd(ENABLE);/*ConfigureRTCclocksourceandprescaler*/RTC_Configuration();/*WaittillRTCSecon说论宗职否波谓块护deventoccurs火正引础声旧太危音*/RTC_ClearFlag(RTC_FLAG_SEC);while(RTC_GetFlagStatus(RTC_FLAG_SEC)==RESET);#ifdefWKUP_20s/*SettheRTCAlarmafter20s(=327000*61µs)*/RTC_SetAlarm(RTC_GetCounter()+327000);#else#ifdefWKUP_200ms/*Setth观找余eRTCAlarmafter200ms(=3276*61µs)*/RTC_SetAlarm(RTC_Get万氧Counter()+3276)价;#endif#endif/*ConfigureADCconvers校系经望尔ionmode*/ADC_Configuration();/*A王输连增导层笑早开亮逐DC1regularSoftwareStartConv*/ADC_SoftwareSt取研少加调拉家附就钱言artConvCmd(AD完北临环里先短安教C1,ENABLE);/*TestEOCflag*/while(!ADC_GetFlagStatus(ADC1发另们图阳培行消,ADC_FLAG_EOC));/*较坏教牛单ReadregularconverteddataandclearEOCFlag*/RegularConvData=ADC_GetConversionValue(ADC1训管);ADC_Cmd(ADC1,DISABLE);/*Turnonledconne节议ctedtoPC.01*/GPIO_ResetBits(GPIOC,GPIO_Pin_1);/*WaituntillastwriteoperationonRTCregistershasfinished*/RTC_WaitForLastTask();/*RequesttoenterSTANDBYmode(WakeUpflagisclearedinPWR_EnterSTANDBYModefunction)*/PWR_EnterSTANDBYMode();while(1){}}/***@briefEntersSTANDBYmode.*@paramNone*@retval:None*/voidPWR_EnterSTANDBYMode(void){/*ClearWake-upflag*/PWR->CR|=CR_CWUF_Set;/*SelectSTANDBYmode*/PWR->CR|=CR_PDDS_Set;/*SetSLEEPDEEPbitofCortexSystemControlRegister*/*(__IOuint32_t*)SCB_SysCtrl|=SysCtrl_SLEEPDEEP_Set;/*Thisoptionisusedtoensurethatstoreoperationsarecompleted*/#ifdefined(__CC_ARM)__force_stores();#endif/*RequestWaitForInterrupt*/__WFI();}看不到源码的函数在STM32的库可以看到,希望对你有帮助有问题在email我

评论