ch32v003進(jìn)入待機(jī)模式后,外部中斷喚醒后怎么進(jìn)不去待機(jī)模式了

#include "debug.h"


/* Global define */


/* Global Variable */


/*********************************************************************

?* @fn? ? ? EXTI_INT_INIT

?*

?* @brief? ?Initializes EXTI collection.

?*

?* @return? none

?*/

void EXTI_INT_INIT(void)

{

? ? EXTI_InitTypeDef EXTI_InitStructure = {0};


? ? RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);


? ? EXTI_InitStructure.EXTI_Line = EXTI_Line9;

? ? EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;

? ? EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

? ? EXTI_InitStructure.EXTI_LineCmd = ENABLE;

? ? EXTI_Init(&EXTI_InitStructure);

}


/*********************************************************************

?* @fn? ? ? EXTI0_INT_INIT

?*

?* @brief? ?Initializes EXTI0 collection.

?*

?* @return? none

?*/

void EXTI0_INT_INIT(void)

{

? ? GPIO_InitTypeDef GPIO_InitStructure = {0};

? ? EXTI_InitTypeDef EXTI_InitStructure = {0};

? ? NVIC_InitTypeDef NVIC_InitStructure = {0};


? ? RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO? | RCC_APB2Periph_GPIOC, ENABLE);


? ? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;

? ? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;

? ? GPIO_Init(GPIOC, &GPIO_InitStructure);


//? ? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;

//? ? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;

//? ? GPIO_Init(GPIOC, &GPIO_InitStructure);


? ? /* GPIOC ----> EXTI_Line0 */

? ? GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource0);

? ? EXTI_InitStructure.EXTI_Line = EXTI_Line0;

? ? EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

? ? EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

? ? EXTI_InitStructure.EXTI_LineCmd = ENABLE;

? ? EXTI_Init(&EXTI_InitStructure);


//? ? GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource5);

//? ? EXTI_InitStructure.EXTI_Line = EXTI_Line5;

//? ? EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

//? ? EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

//? ? EXTI_InitStructure.EXTI_LineCmd = ENABLE;

//? ? EXTI_Init(&EXTI_InitStructure);

//

//? ? GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource6);

//? ? EXTI_InitStructure.EXTI_Line = EXTI_Line6;

//? ? EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

//? ? EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

//? ? EXTI_InitStructure.EXTI_LineCmd = ENABLE;

//? ? EXTI_Init(&EXTI_InitStructure);

//

//? ? GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource7);

//? ? EXTI_InitStructure.EXTI_Line = EXTI_Line7;

//? ? EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

//? ? EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

//? ? EXTI_InitStructure.EXTI_LineCmd = ENABLE;

//? ? EXTI_Init(&EXTI_InitStructure);


? ? NVIC_InitStructure.NVIC_IRQChannel = EXTI7_0_IRQn;

? ? NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

? ? NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

? ? NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

? ? NVIC_Init(&NVIC_InitStructure);

}


/*********************************************************************

?* @fn? ? ? main

?*

?* @brief? ?Main program.

?*

?* @return? none

?*/

int main(void)

{

//? ? GPIO_InitTypeDef GPIO_InitStructure = {0};


? ? NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

? ? SystemCoreClockUpdate();

? ? Delay_Init();

? ? Delay_Ms(1000);

? ? Delay_Ms(1000);

//? ? EXTI_INT_INIT();

//

//

//? ? RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE);

//? ? RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

//? ? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

//? ? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;

//

//? ? GPIO_Init(GPIOA, &GPIO_InitStructure);

//? ? GPIO_Init(GPIOC, &GPIO_InitStructure);

//? ? GPIO_Init(GPIOD, &GPIO_InitStructure);


#if (SDI_PRINT == SDI_PR_OPEN)

? ? SDI_Printf_Enable();

#else

? ? USART_Printf_Init(115200);

#endif

? ? printf("SystemClk:%d\r\n", SystemCoreClock);

? ? printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );

? ? printf("Standby Mode Test\r\n");

? ? printf("0x1FFFF800-%08x\r\n", *(u32*)0x1FFFF800);


? ? EXTI0_INT_INIT();


//? ? RCC_LSICmd(ENABLE);

//? ? while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);

//? ? PWR_AWU_SetPrescaler(PWR_AWU_Prescaler_10240);

//? ? PWR_AWU_SetWindowValue(25);

//? ? PWR_AutoWakeUpCmd(ENABLE);

? ? PWR_EnterSTANDBYMode(PWR_STANDBYEntry_WFI);


? ? #if (SDI_PRINT == SDI_PR_OPEN)

? ? SDI_Printf_Enable();

#else

? ? USART_Printf_Init(115200);

#endif

? ? printf("\r\n Auto wake up \r\n");

? ? while(1)

? ? {

? ? ? ? Delay_Ms(1000);

? ? ? ? Delay_Ms(1000);

? ? ? ? printf("Run in main\r\n");

? ? ? ? RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

? ? ? ? EXTI0_INT_INIT();

? ? ? ? PWR_EnterSTANDBYMode(PWR_STANDBYEntry_WFI);

? ? }

}


icon_rar.gifCH32V003 待機(jī)模式喚醒.zip



?if(EXTI_GetITStatus(EXTI_Line0)!=RESET)

? ? {

? ? ? ? printf("Run at EXTI0\r\n");

? ? ? ? EXTI_ClearITPendingBit(EXTI_Line0);? ? ?/* Clear Flag */

? ? }

中斷函數(shù)中再加個判斷,清空標(biāo)志。


可以了


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

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