哪位高手帮解答一下我的问题
芯片:STM32L151VCH6
电源:3.3v
LSE:32.768khz
编译环境:MDK4.74
目前测试板上只焊了一个STM32L151,GPIO都处在悬空状态。经测试进入Standby模式功耗正常,电流不到1微安。但是进入STOP模式电流是1mA左右,与手册上面值相差很大。希望高手们帮助解决一下。谢谢
下面是程序代码
int main(void)
{
RccInit();
GPIOInit();
FLASH->ACR = FLASH_ACR_SLEEP_PD;
SCB->SCR |= SCB_SCR_SLEEPDEEP;
PWR->CR &=~ PWR_CR_PDDS;
PWR->CR = PWR_CR_LPSDSR;
PWR->CR |= PWR_CR_ULP;
PWR->CSR &=~ PWR_CSR_WUF;
__WFI();
temp = temp;
while(1);
}
void RccInit(void)
{
RCC->CR = RCC_CR_MSION;
while((RCC->CR & RCC_CR_MSIRDY)==0); //等待MSI时钟就绪
RCC->ICSCR =
// RCC_ICSCR_MSIRANGE_0; //< Internal Multi Speed clock Range 65.536 KHz
// RCC_ICSCR_MSIRANGE_1; //< Internal Multi Speed clock Range 131.072 KHz
RCC_ICSCR_MSIRANGE_2; //< Internal Multi Speed clock Range 262.144 KHz
// RCC_ICSCR_MSIRANGE_3; //< Internal Multi Speed clock Range 524.288 KHz
// RCC_ICSCR_MSIRANGE_4; //< Internal Multi Speed clock Range 1.048 MHz
// RCC_ICSCR_MSIRANGE_5; //< Internal Multi Speed clock Range 2.097 MHz
// RCC_ICSCR_MSIRANGE_6; //< Internal Multi Speed clock Range 4.194 MHz
RCC->CFGR = RCC_CFGR_SW_MSI;
while((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_MSI);
RCC->AHBENR = RCC_AHBENR_FLITFEN
+RCC_AHBENR_GPIOAEN
+RCC_AHBENR_GPIOBEN
+RCC_AHBENR_GPIOCEN
+RCC_AHBENR_GPIODEN
+RCC_AHBENR_GPIOEEN;
RCC->APB2ENR = RCC_APB2ENR_SPI1EN;
RCC->APB1ENR = RCC_APB1ENR_PWREN
+RCC_APB1ENR_SPI2EN
+RCC_APB1ENR_SPI3EN;
RCC->AHBLPENR = 0;
RCC->APB1LPENR = 0;
RCC->APB2LPENR = 0;
PWR->CR |= PWR_CR_DBP
+PWR_CR_PVDE
+PWR_CR_CWUF;
RCC->CSR |= RCC_CSR_LSEON;
while((RCC->CSR & RCC_CSR_LSERDY) == 0);
//配置RTC时钟源
RCC->CSR |= RCC_CSR_RTCEN;
RCC->CSR |= RCC_CSR_RTCSEL_LSE;
RCC->CSR |= RCC_CSR_LSECSSON; //使能LSE时钟源安全系统
RCC->CIR = RCC_CIR_LSECSSC;
// RCC->CIR = RCC_CIR_LSECSSIE;
}
void GPIOInit(void)
{
//----GPIOA
GPIOA->MODER = GPIO_MODER_MODER1_0 //PA1 推挽、无上下拉输出 exADC_SCK
+GPIO_MODER_MODER4_0 //PA4 推挽、无上下拉输出 FLASH_CS
+GPIO_MODER_MODER13_1 //PA13 SWDIO
+GPIO_MODER_MODER14_1 //PA14 SWCLK
+GPIO_MODER_MODER15_0; //PA15 推挽、无上下拉输出 RF_CS
GPIOA->OTYPER = 0;
GPIOA->PUPDR = 0;
GPIOA->ODR = BIT1;
//----GPIOB
GPIOB->MODER = GPIO_MODER_MODER3_1 //PB3 可编程、推挽、无上下拉输出 RF_SCK
+GPIO_MODER_MODER4_1 //PB4 可编程、推挽、无上下拉输出 RF_MISO
+GPIO_MODER_MODER5_1 //PB5 可编程、推挽、无上下拉输出 RF_MOSI
+GPIO_MODER_MODER12_0 //PB12 推挽、无上下拉输出 FLASH_HOLD
+GPIO_MODER_MODER13_1; //PB13 可编程、推挽、无上下拉输出 3g_SCK
GPIOB->OTYPER = 0;
GPIOB->PUPDR = 0;
GPIOB->AFR[0] = GPIO_AFRL_AFRL3/0x0f*6
+GPIO_AFRL_AFRL4/0x0f*6
+GPIO_AFRL_AFRL5/0x0f*6;
GPIOB->AFR[1] = GPIO_AFRH_AFRH13/0x0f*5;
//----GPIOC
GPIOC->MODER = 0; //PC0 浮空输入 exADC_DAT
GPIOC->OTYPER = 0;
GPIOC->PUPDR = 0;
//----GPIOD
GPIOD->MODER = GPIO_MODER_MODER0_0 //PD0 推挽、无上下拉输出 3g_CS
+GPIO_MODER_MODER3_1 //PD3 可编程、推挽、无上下拉输出 3g_SDO
+GPIO_MODER_MODER4_1 //PD4 可编程、推挽、无上下拉输出 3g_SDI
+0 //PD5 浮空输入 3g_INT2
+0 //PD7 浮空输入 3g_INT1
+GPIO_MODER_MODER8_0; //PD8 推挽、无上下拉输出 exADC_SLEEP
GPIOD->OTYPER = 0;
GPIOD->PUPDR = 0;
GPIOD->AFR[0] = GPIO_AFRL_AFRL3/0x0f*5
+GPIO_AFRL_AFRL4/0x0f*5;
GPIOD->ODR = BIT0;
//----GPIOE
GPIOE->MODER = 0 //PE1 上拉输入 RF_IRQ
+GPIO_MODER_MODER3_0 //PE3 推挽、无上下拉输出 RF_CSN
+GPIO_MODER_MODER11_0 //PE11 推挽、无上下拉输出 FLASH_WP
+GPIO_MODER_MODER13_1 //PE13 可编程、推挽、无上下拉输出 FLASH_SCK
+GPIO_MODER_MODER14_1 //PE14 可编程、推挽、无上下拉输出 FLASH_SDO
+GPIO_MODER_MODER15_1; //PE15 可编程、推挽、无上下拉输出 FLASH_SDI
GPIOE->OTYPER = 0;
GPIOE->PUPDR = GPIO_PUPDR_PUPDR1_0;
GPIOE->AFR[1] = GPIO_AFRH_AFRH13/0x0f*5
+GPIO_AFRH_AFRH14/0x0f*5
+GPIO_AFRH_AFRH15/0x0f*5;
}
|