2021-02-05 12:44 AM
Hallo
I use STM32F779 and want to enter this device in Standby mode and wake up via Wake up pin (PA0). The problem is that everything only works one time correctly or it complete its loop first time just correctly.
After the Reset, Microcontroller goes in Standby mode and stay till rise edge of wake up pin. Then it wakes up from Standby mode and again goes to standby mode. But this process just one time works but after first loop it is not working . because next time it dosn't stay in standby mode and wakes up itself and goes to standby mode again and again without any action in Wake up pin.
Here is my code:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
}
HAL_Delay(3000);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
for (int var = 0; var < 8; ++var)
{
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
HAL_Delay(100);
}
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
HAL_PWR_EnterSTANDBYMode();
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
2021-02-07 05:35 AM
What's connected to PA0, i.e. how the rising edge is generated?
2021-02-08 06:21 AM
A push button.
2021-02-15 01:04 AM
I did it with a WWDG:
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
{
/* Wakeup from the standby mode */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
for (int var = 0; var < 6; ++var)
{
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
HAL_Delay(300);
}
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN3);
if (HAL_WWDG_Init(&hwwdg) != HAL_OK)
{
Error_Handler();
}
}
2021-07-09 10:59 AM
Replace the CPU and reconsider what may want to have happend that you broke it. Some terrible program would allow connect beneath reset however now not smash the CPU. And the CPU breaks for some cause as you can read. So think what may want to have came about! ESD?
2024-10-17 02:44 AM
I was having the same problem, if you're reading this topic and have the same problem. I just get rid of it by modifying my original code with HAL_SuspendTick() function and it stops randomly waking up. Also clock source is selected as MSI 2.097Mhz, Mcu is STM32L010c6t6 and using SSD1306 library with my own pcb.
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "ssd1306.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
I2C_HandleTypeDef hi2c1;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_I2C1_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2C1_Init();
/* USER CODE BEGIN 2 */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
ssd1306_Init();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_ResumeTick();
ssd1306_Fill(White);
ssd1306_UpdateScreen();
HAL_GPIO_WritePin(GPIOB, LED_Pin, SET);
HAL_Delay(6000);
HAL_GPIO_WritePin(GPIOB, LED_Pin, RESET);
ssd1306_Fill(Black);
ssd1306_UpdateScreen();
HAL_Delay(1000);
HAL_SuspendTick();
HAL_PWR_EnterSTANDBYMode();
}
/* USER CODE END 3 */
}