Hi,
下列程式碼顯示AMB82-mini在wifi連線下無法進入待機模式;
//Source code:
/*
This sketch shows how to use power mode standby
Example guide:
PowerMode – Standby Mode – Realtek IoT/Wi-Fi MCU Solutions
*/
#include “PowerMode.h”
#include <WiFi.h>
// wake up by AON timer : 0
// wake up by AON GPIO : 1
// wake up by RTC : 2
// wake up by PON GPIO : 3
// wake up by UART/Serial1 : 4 //Only support 4MHz clock source
// wake up by Gtimer0 : 5 //Only support 4MHz clock source
#define WAKEUP_SOURCE 1
#if (WAKEUP_SOURCE == 0)
// set AON timer Clock, 1: 4MHz, 0: 100kHz
#define CLOCK 0
// set AON timer sleep duration, 5s
#define SLEEP_DURATION 5
uint32_t PM_AONtimer_setting[2] = {CLOCK, SLEEP_DURATION};
#define WAKUPE_SETTING (uint32_t)(PM_AONtimer_setting)
#elif (WAKEUP_SOURCE == 1)
// set wake up AON GPIO pin : 21 / 22
#define WAKUPE_SETTING 21
#elif (WAKEUP_SOURCE == 2)
// set wake up RTC alarm as 5 seconds
#define ALARM_DAY 0
#define ALARM_HOUR 0
#define ALARM_MIN 0
#define ALARM_SEC 5
uint32_t PM_rtc_Alarm[4] = {ALARM_DAY, ALARM_HOUR, ALARM_MIN, ALARM_SEC};
#define WAKUPE_SETTING (uint32_t)(PM_rtc_Alarm)
#elif (WAKEUP_SOURCE == 3)
// set wake up PON GPIO pin : 0 to 11
#define WAKUPE_SETTING 0
#elif (WAKEUP_SOURCE == 5)
// set wake up Gtimer0 sleep duration, 5s
#define SLEEP_DURATION 5
#define WAKUPE_SETTING SLEEP_DURATION
#else
#define WAKUPE_SETTING 0
#endif
char ssid = “POCO”;
char pass = “123456789”;
void setup()
{
Serial.begin(115200);
Serial.println(“Standby Mode Demo!”);
//mikettest-2024-07-17------
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
//mikettest-2024-07-17------
PowerMode.begin(STANDBY_MODE, WAKEUP_SOURCE, WAKUPE_SETTING);
for (int i = 5; i > 0; i--) {
Serial.print("Enter Standby Mode by ");
Serial.print(i, DEC);
Serial.println(" seconds.");
delay(1000);
}
PowerMode.start();
// the default RTC start at 1970.1.1 00:00:00
// customize the start time by PowerMode.start(1970, 1, 1, 0, 0, 0);
Serial.println("You won't see this log");
while (1)
;
}
void loop()
{
delay(1000);
}
//log:
15:34:42.074 → Boot Loader <==
15:34:42.074 →
15:34:42.074 → == RAM Start ==
15:34:42.074 → Build @ 14:48:33, Jun 6 2024
15:34:42.118 → $8735b>Standby Mode Demo!
15:34:42.118 → interface 0 is initialized
15:34:42.118 → interface 1 is initialized
15:34:42.118 → cfg_size_lib = 33, cfg_size_user = 33
15:34:42.118 →
15:34:42.118 → Initializing WIFI …[Driver]: [HALMAC]
15:34:42.118 → 11692M HALMAC_MAJOR_VER = 1
15:34:42.118 → HALMAC_PROTOTYPE_VER = 4
15:34:42.118 → HALMAC_MINOR_VER = 20
15:34:42.118 → HALMAC_PATCH_VER =
15:34:42.118 → [Driver]: The driver include MP
15:34:42.164 → [Driver]: Ver = libwlan:2024.06.06.15.18_bBranch_c9ac9463_a4bceabfd2147eb65f520240ea916875e8c1791b
15:34:42.164 → RFE type = 0
15:34:42.209 → start_addr=(0x4000), end_addr=(0x8000), buffer_size=(0x4000), smp_number_max=(2048)
15:34:42.241 →
15:34:42.241 → WIFI initialized
15:34:42.241 →
15:34:46.640 →
15:34:46.899 → [Driver]: association success(res=16)
15:34:46.935 →
15:34:46.935 → [Driver]: set pairwise key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4)
15:34:46.970 →
15:34:46.970 → [Driver]: set group key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4) keyid:1
15:34:46.970 → (0) Scan: 1, Auth: 1, Assoc: 1, 4way: 1, connect: 1, reason: 0
15:34:46.970 →
15:34:47.623 → Interface 0 IP address : 192.168.36.153
15:34:47.658 → GPIO IRQ init OK!
15:34:47.658 → Enter Standby Mode by 5 seconds.
15:34:48.237 → [Driver]: random drift
15:34:48.237 →
15:34:48.237 → Enter Standby Mode by 4 seconds.
15:34:49.671 → Enter Standby Mode by 3 seconds.
15:34:50.632 → Enter Standby Mode by 2 seconds.
15:34:51.670 → Enter Standby Mode by 1 seconds.
15:34:52.634 → You won’t see this log
15:34:59.303 → [Driver]: random drift
15:34:59.303 →
15:34:59.303 → [Driver]: random drift
15:35:11.281 →
15:35:11.281 → [Driver]: TSFValue = 2653799749, tsf = 0, shift_set= 0x8000, bcn int = 100
15:35:23.244 →
15:35:23.244 →