EXTI15_10_IRQHandler無法喚醒處于standby狀態(tài)的CH32L103C8T6,何解?

先說實(shí)驗(yàn)結(jié)論:直接采用官方評估版與評估代碼,PA0可以順利喚醒MCU,但是自己寫的外部中斷函數(shù)無法喚醒


實(shí)驗(yàn)內(nèi)容:


先看參考手冊

1721126238824988.png


再貼代碼,直接拿CH32L103EVT.ZIP壓縮包中的CH32L103EVT.ZIP\EVT\EXAM\PWR\Standby_Mode\修改

/*********************************************************************
?*?@fn??????EXTI15_10_IRQHandler
?*
?*?@brief???This?function?handles?EXTI10~15?Handler.
?*
?*?@return??none
?*/
void?EXTI15_10_IRQHandler(void)?__attribute__((interrupt("WCH-Interrupt-fast")));
void?EXTI15_10_IRQHandler(void)
{
????//KEY2?pressed
????if(EXTI_GetITStatus(EXTI_Line14)!=RESET)
????{
????????EXTI_ClearITPendingBit(EXTI_Line14);?????/*?Clear?Flag?*/
????????printf("PB14?wakeup!\r\n");
????????return;
????}
}


/*********************************************************************
?*?@fn??????main
?*
?*?@brief???Main?program.
?*
?*?@return??none
?*/
int?main(void)
{
????GPIO_InitTypeDef?GPIO_InitStructure?=?{0};
????EXTI_InitTypeDef?EXTI_InitStructure?=?{0};
????NVIC_InitTypeDef?NVIC_InitStructure?=?{0};

????/*?To?reduce?power?consumption,?unused?GPIOs?need?to?be?set?as?pull-down?inputs?*/
????RCC_PB2PeriphClockCmd(RCC_PB2Periph_GPIOA|RCC_PB2Periph_GPIOB|
????????????RCC_PB2Periph_GPIOC|RCC_PB2Periph_GPIOD,?ENABLE);
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_All;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IPD;

????GPIO_Init(GPIOA,?&GPIO_InitStructure);
????GPIO_Init(GPIOB,?&GPIO_InitStructure);
????GPIO_Init(GPIOC,?&GPIO_InitStructure);
????GPIO_Init(GPIOD,?&GPIO_InitStructure);

????NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

????//PB14?is?used?as?wake?up?key
????GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,?GPIO_PinSource14);
????EXTI_InitStructure.EXTI_Line?=?EXTI_Line14;
????EXTI_InitStructure.EXTI_Mode?=?EXTI_Mode_Interrupt;
????EXTI_InitStructure.EXTI_Trigger?=?EXTI_Trigger_Rising;
????EXTI_InitStructure.EXTI_LineCmd?=?ENABLE;
????EXTI_Init(&EXTI_InitStructure);

????NVIC_InitStructure.NVIC_IRQChannel?=?EXTI15_10_IRQn;
????NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority?=?1;
????NVIC_InitStructure.NVIC_IRQChannelSubPriority?=?1;
????NVIC_InitStructure.NVIC_IRQChannelCmd?=?ENABLE;
????NVIC_Init(&NVIC_InitStructure);

????SystemCoreClockUpdate();
????Delay_Init();
????USART_Printf_Init(115200);
????printf("SystemClk:%d\r\n",?SystemCoreClock);
????printf(?"ChipID:%08x\r\n",?DBGMCU_GetCHIPID()?);
????printf("Standby?Mode?Test\r\n");

????RCC_PB1PeriphClockCmd(RCC_PB1Periph_PWR,?ENABLE);

????if(PWR_GetFlagStatus(PWR_FLAG_WU)?==?SET)
????{
????????printf("\r\n?Standby?wake?up?reset?\r\n");
????}
????else
????{
????????printf("\r\n?Power?on?reset?\r\n");
????????PWR_WakeUpPinCmd(ENABLE);
????????PWR_EnterSTANDBYMode();
????}

????printf("\r\n?##########?\r\n");
????while(1)
????{
????????Delay_Ms(1000);
????????printf("Run?in?main\r\n");
????}
}


結(jié)果就是沒有進(jìn)入standby狀態(tài),在執(zhí)行while(1)這個循環(huán)時,把PB14拉高能觸發(fā)中斷,串口也能看到輸出

PB14?wakeup!

但是斷電重新上電后,顯示:

SystemClk:96000000

ChipID:10310710

Standby Mode Test


?Power on reset?


這時就PB14再沒法喚醒MCU了,這時將PA0拉高能喚醒。

這與手冊描述的不一致,是不是還需要哪些地方設(shè)置?


我已經(jīng)琢磨出來了,根據(jù)手冊片段描述,猜測是不是要將自定義的外部中斷改成事件?


1721142166646124.png


如下修改:

1721142359108066.png


果然,原來毫無反應(yīng)的板子直接重啟了,符合手冊中standby喚醒執(zhí)行電源復(fù)位動作的描述。


看來官方手冊還得反反復(fù)復(fù)仔仔細(xì)細(xì)去讀,去體會(猜)




只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频