ch32L103用LPTIM從STOP喚醒失?。ú灏坞娫矗?

用復(fù)位鍵啟動(dòng)程序可正常運(yùn)行?

拔電源再插會(huì)失敗導(dǎo)致一直在stop模式無(wú)法喚醒


void LPTIM_Init(u16 arr)
{
??? NVIC_InitTypeDef NVIC_InitStructure = {0};
??? LPTIM_TimeBaseInitTypeDef?? LPTIM_TimeBaseInitStruct = {0};
??? RCC_PB2PeriphClockCmd(RCC_PB2Periph_GPIOB, ENABLE);
??? RCC_PB1PeriphClockCmd(RCC_PB1Periph_LPTIM, ENABLE);

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

??? LPTIM_Cmd(ENABLE);


??? RCC_LSICmd(ENABLE);
??? while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY)!=SET);



??? LPTIM_TimeBaseInitStruct.LPTIM_ClockSource = LPTIM_ClockSource_In;
??? LPTIM_TimeBaseInitStruct.LPTIM_CountSource = LPTIM_CountSource_Internal;
??? LPTIM_TimeBaseInitStruct.LPTIM_ClockPrescaler = LPTIM_TClockPrescaler_DIV128;
??? LPTIM_TimeBaseInitStruct.LPTIM_InClockSource = LPTIM_InClockSource_LSI;

??? LPTIM_TimeBaseInitStruct.LPTIM_ClockPolarity = LPTIM_ClockPolarity_Falling;
??? LPTIM_TimeBaseInitStruct.LPTIM_ClockSampleTime = LPTIM_ClockSampleTime_0T;
??? LPTIM_TimeBaseInitStruct.LPTIM_TriggerSampleTime = LPTIM_TriggerSampleTime_0T;
??? LPTIM_TimeBaseInitStruct.LPTIM_ExTriggerPolarity = LPTIM_ExTriggerPolarity_Disable;
??? LPTIM_TimeBaseInitStruct.LPTIM_TimeOut = DISABLE;
??? LPTIM_TimeBaseInitStruct.LPYIM_OutputPolarity = LPYIM_OutputPolarity_High;
??? LPTIM_TimeBaseInitStruct.LPYIM_UpdateMode = LPYIM_UpdateMode0;
??? LPTIM_TimeBaseInitStruct.LPTIM_Encoder = DISABLE;
??? LPTIM_TimeBaseInitStruct.LPTIM_ForceOutHigh = DISABLE;
??? LPTIM_TimeBaseInitStruct.LPTIM_SingleMode = DISABLE;
??? LPTIM_TimeBaseInitStruct.LPTIM_ContinuousMode = ENABLE;
??? LPTIM_TimeBaseInitStruct.LPTIM_PWMOut = DISABLE;
??? LPTIM_TimeBaseInitStruct.LPTIM_CounterDirIndicat = DISABLE;
??? LPTIM_TimeBaseInitStruct.LPTIM_Pulse = 0;
??? LPTIM_TimeBaseInitStruct.LPTIM_Period = arr;

??? LPTIM_TimeBaseInit( & LPTIM_TimeBaseInitStruct);
??? LPTIM_ITConfig(LPTIM_IT_ARRM, ENABLE);
}


int main(void)
{
??? NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
??? SystemCoreClockUpdate();
??? Delay_Init();
??? Delay_Ms(5000);
??? USART_Printf_Init(9600);
??? printf("SystemClk:%d\r\n", SystemCoreClock);
??? printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );
??? RCC_PB1PeriphClockCmd(RCC_PB1Periph_PWR, ENABLE);
??? gpioinit();

??? LPTIM_Init(2000);

??? while(1)
??? {
??????? printf("Welcome to WCH\r\n");
??????? GPIO_WriteBit(GPIOA, GPIO_Pin_15, 0);
??????? Delay_Ms(1000);
??????? GPIO_WriteBit(GPIOA, GPIO_Pin_15, 1);
??????? PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
??? }
}

void LPTIM_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));

void LPTIM_IRQHandler(void)
{
??? if((LPTIM_GetFlagStatus(LPTIM_FLAG_ARRM)==SET))
??? {
??????? LPTIM_ClearFlag(LPTIM_FLAG_ARRM);
???? }

}

用的是標(biāo)準(zhǔn)開(kāi)發(fā)板 LPTIM例程也出現(xiàn)同樣的問(wèn)題


簡(jiǎn)化了一下 SW軟啟動(dòng)后正常 再用復(fù)位鍵也正常 拔掉電源再插上又失靈。現(xiàn)在想知道SW軟啟動(dòng)寫(xiě)了那些寄存器 和硬插電后復(fù)位有啥區(qū)別?

void LPTIM_Init(u16 arr)
{
??? NVIC_InitTypeDef NVIC_InitStructure = {0};
??? LPTIM_TimeBaseInitTypeDef?? LPTIM_TimeBaseInitStruct = {0};
??? RCC_PB1PeriphClockCmd(RCC_PB1Periph_LPTIM, ENABLE);

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

??? RCC_LSICmd(ENABLE);
??? while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY)!=SET);

??? LPTIM_Cmd(ENABLE);

??? LPTIM_TimeBaseInitStruct.LPTIM_ClockSource = LPTIM_ClockSource_In;
??? LPTIM_TimeBaseInitStruct.LPTIM_CountSource = LPTIM_CountSource_Internal;
??? LPTIM_TimeBaseInitStruct.LPTIM_ClockPrescaler = LPTIM_TClockPrescaler_DIV128;
??? LPTIM_TimeBaseInitStruct.LPTIM_InClockSource = LPTIM_InClockSource_LSI;
?
??? LPTIM_TimeBaseInitStruct.LPTIM_ContinuousMode = ENABLE;
??? LPTIM_TimeBaseInitStruct.LPTIM_Period = arr;

??? LPTIM_TimeBaseInit( & LPTIM_TimeBaseInitStruct);
??? LPTIM_ITConfig(LPTIM_IT_ARRM, ENABLE);

}


您好,目前這邊已經(jīng)復(fù)現(xiàn)了你的問(wèn)題,這邊具體看一下,有結(jié)論后會(huì)及時(shí)給予你回復(fù)。后續(xù)若有問(wèn)題,也可郵箱(lzs@wch.cn)和我進(jìn)行溝通。


您好,關(guān)于LPTIM喚醒,在使用時(shí)需要對(duì)EXTI21進(jìn)行配置,EVT后面會(huì)修改更新,可參考一下附件例程。后面若有問(wèn)題,可郵箱(lzs@wch.cn)溝通。

icon_rar.gifCH32L103 LPTIM.zip



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

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