2016-12-08 12:42 AM
Hi,
I'm trying to wake up my device from the sleep mode and i'm asking this question : What's the difference between BUTTON MODE EXTI and BUTTON MODE GPIO ? Thank you ! Have a nice day !Solved! Go to Solution.
2016-12-08 03:50 AM
Hi
Michel.Leo
,EXTI mode and GPIO mode are a software designationused in the driver to configure the GPIO pin in possible available mode :
BUTTON MODE GPIO : used to configure the IO in output mode (PP or OD) or in alternate function AF (PP or OD)
BUTTON MODE EXTI: used to configure the IO in interruptionsensitive mode ( in driver SYSCFG and EXTI register are configured )
IF this response is helpful , pushh correct buttom.
-Walid F-
2016-12-08 03:17 AM
Hi
Michel.Leo
,BUTTON_MODE_GPIO: Button will be used as simple IO
BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt generation capability
-Nesrine-
Ifmy suggestanswers your question, please mark it as correct.
2016-12-08 03:50 AM
Hi
Michel.Leo
,EXTI mode and GPIO mode are a software designationused in the driver to configure the GPIO pin in possible available mode :
BUTTON MODE GPIO : used to configure the IO in output mode (PP or OD) or in alternate function AF (PP or OD)
BUTTON MODE EXTI: used to configure the IO in interruptionsensitive mode ( in driver SYSCFG and EXTI register are configured )
IF this response is helpful , pushh correct buttom.
-Walid F-
2016-12-08 04:55 AM
If I understand, when i push the button in the MODE EXTI, I generate an interruption.
So for exemple in the below code, normally if I'm in the sleep mode and I press on the user button, i should wake up the device from the sleep. But it doesn't work ... I do the following steps :
- I press the reset Button, - I press the user button to enter in the sleep mode (as it programmed in the main) - The LED4 is blinking. - I press the user button - The LED4 continues to blink. I think that normally I should wake up the device from the sleep mode and then go back to the main programm and on this main, the code should switch on the LED3.../* Configure User Button */
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
/* Request to enter SLEEP mode */
__WFI();
/* Initialize LED4 on STM32F0-Discovery board */
STM_EVAL_LEDInit(LED4);
/* Infinite loop */
while (1)
{
/* Toggle The LED4 */
STM_EVAL_LEDToggle(LED4);
/* Inserted Delay */
for(index = 0; index < 0x7FFFF; index++);
}
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Here is the entire code :
void SleepMode_Measure(void)
{
__IO uint32_t index = 0;
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure all GPIO as analog to reduce current consumption on non used IOs */
/* Enable GPIOs clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC |
RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOF , ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Disable GPIOs clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC |
RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOF, DISABLE);
/* Configure User Button */
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
/* Request to enter SLEEP mode */
__WFI();
/* Initialize LED4 on STM32F0-Discovery board */
STM_EVAL_LEDInit(LED4);
/* Infinite loop */
while (1)
{
/* Toggle The LED4 */
STM_EVAL_LEDToggle(LED4);
/* Inserted Delay */
for(index = 0; index < 0x7FFFF; index++);
}
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f0xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f0xx.c file
*/
/* Configure User Button */
STM_EVAL_PBInit(BUTTON_USER,BUTTON_MODE_GPIO);
/* Loop while User button is maintained pressed */
while(STM_EVAL_PBGetState(BUTTON_USER) != RESET)
{
}
/* Enable PWR APB1 Clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Allow access to Backup */
PWR_BackupAccessCmd(ENABLE);
/* Reset RTC Domain */
RCC_BackupResetCmd(ENABLE);
RCC_BackupResetCmd(DISABLE);
/* Loop while User button is maintained pressed */
while(STM_EVAL_PBGetState(BUTTON_USER) == RESET)
{
}
/* Loop while User button is maintained pressed */
while(STM_EVAL_PBGetState(BUTTON_USER) != RESET)
{
}
#if defined (SLEEP_MODE)
/* Sleep Mode Entry
- System Running at PLL (48MHz)
- Flash 3 wait state
- Prefetch and Cache enabled
- Code running from Internal FLASH
- All peripherals disabled.
- Wakeup using EXTI Line (User Button PA.00)
*/
SleepMode_Measure();
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
2016-12-08 05:34 AM
Thank you !
2016-12-08 06:23 AM
Hi
Michel.Leo
I recommend you to start from the PWR examples under the
:STM32F0xx_StdPeriph_Lib_V1.5.0\Projects\STM32F0xx_StdPeriph_Examples\PWR\PWR_Standby: This example shows how to enter the system to STANDBY mode and wake-up from this mode either with the RESET or using RTC Alarm.
- Sleep Mode
- STOP mode with RTC
- STANDBY mode without RTC
- STANDBY mode with RTC
-Nesrine-
Ifmy suggestanswers your question, please mark it as correct.