WKUP pin functionality Not Working on CH32L103C8T6 - Please help!

I need to use PA0 pin's WKUP function to wake up the chip, but it is not working. I need some help, since the datasheet information is not very clear. I assumed that the WKUP functionality was enabled by only setting up the GPIO as Alternate function and the EWUP bit in?PWR_CSR register.


My main problem is that I am using PB0 separately for an interrupt, so I already configured EXTI0 to work with it... And?I was hoping that WKUP pin functionality would work independently of EXTI/NVIC configurations, so it would not depend on EXTI0 !


Please help to clarify what is wrong and how to correct it. If there is some example of WKUP pin for CH32L103, please share it! Any help will be greatly appreciated.


My pseudocode is as follows...



static void Wake_Pin_Init(void)

{

? GPIO_InitTypeDef? GPIO_InitStructure={0};

? RCC_PB2PeriphClockCmd(RCC_PB2Periph_GPIOA, ENABLE);

? RCC_PB1PeriphClockCmd(RCC_PB1Periph_PWR, ENABLE);


? GPIO_InitStructure.GPIO_Pin =?GPIO_Pin_0;

? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;

? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

? GPIO_Init(GPIOA, &GPIO_InitStructure);

? /* Don't need to setup interrupt, since WKUP function is not an Interrupt, but an exclusive functionality of PA0! (?) */

? PWR_WakeUpPinCmd(ENABLE);

}


static void Modem_Init (void)

{

? ?GPIO_InitTypeDef? GPIO_InitStructure;

? EXTI_InitTypeDef EXTI_InitStructure;

? NVIC_InitTypeDef NVIC_InitStructure;


? RCC_PB2PeriphClockCmd(RCC_PB2Periph_GPIOB, ENABLE);


? GPIO_InitStructure.GPIO_Pin =?GPIO_Pin_0;

? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;

? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

? GPIO_Init(GPIOB, &GPIO_InitStructure);


? /* Interrupt configuration for MODEM */

? ?RCC_PB2PeriphClockCmd(RCC_PB2Periph_AFIO,ENABLE);? /* Enable multiplex function clock */

? /* GPIOB.0 interrupt line and interrupt initialization configuration rising edge trigger */

? GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource0);

? EXTI_InitStructure.EXTI_Line = EXTI_Line0;

? EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

? EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;? /* Rising edge trigger */

? EXTI_InitStructure.EXTI_LineCmd = ENABLE;

? EXTI_Init(&EXTI_InitStructure);? /*Initialize the peripheral EXTI register according to the parameters specified in EXTI_InitStruct*/


? /* Set interrupt priority */

? NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;

? NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;? /* Preemption priority 1, */

? NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x03;

? NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;? /* Enable external interrupt channel */

? NVIC_Init(&NVIC_InitStructure);

? EXTI_ClearITPendingBit(EXTI_Line0);? /* Clear the interrupt flag bit on LINE0 */

}


void main (void)
{

? Init_routine();

? Wake_Pin_Init();

? Modem_Init();

? while (true) {

? ? /* Modem function uses PB0 as an Interrupt */

? ? Do_Something();


? ? PWR_WakeUpPinCmd(ENABLE);

? ? NVIC->SCTLR |= (1 << 4);//SEVONPEND

? ? /* Sleep until the pin is Rising Edge */

? ? PWR_EnterSTOPMode_RAM_LV(PWR_Regulator_LowPower,PWR_STOPEntry_WFI);

? }

}

Hello, there is a routine for waking up the WKUP pin in CH32L103 EVT, located in the PWR folder. The EVT download link is as follows:

http://www.findthetime.net/downloads/CH32L103EVT_ZIP.html

?


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

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