I am new to CubeMX.
How do I configure a pin as and interrupt?
Also how do I setup Low Power sleep mode to wake up with WFI using CubeMX?
Here are the steps, which you need to follow in order to configure the pin as EXTI (External Interrupt).
1. In Pinout tab of STM32CubeMX please click with left mouse button on the pin, which you want to configure. From the menu please select EXTI option. For example below I attached a picture, which shows how to configure PC0 pin as EXTI0.
2. In Configuration tab of STM32CubeMX click on NVIC brick. As a result a window with available interrupts will be opened. From the list please enable EXTI line assigned to the pin. In our case it is EXTI line 0.
3. Optionally if you would like to configure parameters to trigger this interrupt, in the same tab (Configuration) click on GPIO brick. From the list select PC0 and you will be able to select for example edge of signal, which will trigger the interrupt.
4. Now you can geenrate a project for IDE. In the generated code please refer to the file with interrupt handlers. It is named stm32[name of the family]xx_it.c. Inside this file you can find a handler to your interrupt, where you can put your user code.
Regarding your second question: entering low power modes is not managed from STM32CubeMX. You should implement it in code of your application. For example in order to enter Sleep or Low power Sleep mode you need to call function:
Now you can develop a simple application, in which MCU will enter low power mode (Sleep or Low power Sleep) and leave it on EXTI interrupt :-)
Thank you very much for your help.
Please mark Szymon's answer correct rather than your own, that way the metrics are scored properly.
Retrieving data ...