Larry lai
Published © GPL3+

APM32F003 Low power

The APM32F003F6P6 MINIBOARD uses KEY1 (PD1) of the MINIBOARD as the sleep wake up key to control the low power mode and wake up of APM32F003

BeginnerFull instructions provided1 hour270
APM32F003 Low power

Story

Read more

Code

Functions

C Header File
1) MCU runs in normal mode after power-on
2) Press KEY_1 to enter low power mode (RAM and Register data will not be lost)
3) Press KEY_1 again to wake MCU back to normal mode
int main(void) 
{
    GPIO_Config_T gpioConfig;

    gpioConfig.mode = GPIO_MODE_IN_PU;
    gpioConfig.pin = GPIO_PIN_ALL;            
    GPIO_Config(GPIOA, &gpioConfig);                            
    GPIO_Config(GPIOB, &gpioConfig);                    
    GPIO_Config(GPIOC, &gpioConfig);  
    gpioConfig.pin = ((uint8_t)0XF9);    
    GPIO_Config(GPIOD, &gpioConfig);    

    //KEY1 PD6
    gpioConfig.mode = GPIO_MODE_IN_PU;
    gpioConfig.pin = GPIO_PIN_6;
    gpioConfig.intEn = GPIO_EINT_ENABLE;
    EINT_Config(EINT_PORT_D, EINT_TRIGGER_FALLING);
    NVIC_EnableIRQRequest(EINTD_IRQn, 0X01);
    GPIO_Config(GPIOD, &gpioConfig);        

    while(1)    
    {
        if(Sleepflag)
        {        
          PMU_EnterHaltModeWFI();    
        }                    
        
    }
}

Credits

Larry lai
14 projects • 10 followers

Comments