匈奴 发表于 2015-10-29 19:18:24

STM32F030進入與跳出stop mode的作法

我目前用STM32F030K6測試stop mode功能,沒有外接任何OSC(HSE, LSE)
跳出方式是使用EXTI的方式來離開stop mode

ST example code有類似的功能,但都是用LSE當stop mode時的時鐘、並且有增加RTC來喚醒stop mode

請問我以下的寫法正確嗎?
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

/* Allow access to RTC */
PWR_BackupAccessCmd(ENABLE);

/* Reset back up registers */
RCC_BackupResetCmd(ENABLE);
RCC_BackupResetCmd(DISABLE);

/* Enable the LSI OSC */
RCC_LSICmd(ENABLE);

/* Wait till LSI is ready */
while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
{}

    /* Request to enter STOP mode with regulator in low power mode */
    PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);


當跳出stop mode後,範例碼內有加上以下function
   /* Configures system clock after wake-up from STOP */
    SYSCLKConfig_STOP();


static void SYSCLKConfig_STOP(void)
{
/* After wake-up from STOP reconfigure the system clock */
/* Enable HSE */
RCC_HSEConfig(RCC_HSE_ON);

/* Wait till HSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET)
{}

/* Enable PLL */
RCC_PLLCmd(ENABLE);

/* Wait till PLL is ready */
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{}

/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

/* Wait till PLL is used as system clock source */
while (RCC_GetSYSCLKSource() != 0x08)
{}
}


請問我要回到原本用HSI當時鐘的設定要如何修改呢?

謝謝

你好我好大家好! 发表于 2015-10-30 09:01:42

:):):):):):):):):):)                        

yanhaijian 发表于 2015-10-30 11:30:30

感谢分享。

匈奴 发表于 2015-10-30 11:52:03

我是想請各位前輩給我一些指導啊,我分享的都是範例碼而已@@

現在就是跳出stop mode後,也許是時鐘設定的問題,造成stop mode之前的一些功能無法實現

例如I2C等介面,還請各位前輩給予指導
页: [1]
查看完整版本: STM32F030進入與跳出stop mode的作法