TXW82x Low power consumption开发入门: three种休眠mode, 唤醒 IO 与 lowPower_app 接入

Publish in 2026-11-08 22: 00: 11

门铃, 门锁, 电池摄像机这类产品, 大部分时间都in睡觉, 续航好不好全看Low power consumptiondo得怎么样. TXW82x the TXW828 系列supportLow power consumption, SDK 2. 7. 1. 7 也提供the完整the电池摄像机参考方案. 这篇讲three种休眠mode怎么选, 核心port怎么with, 以及怎么把自己the模块接进Low power consumption流程.

内容整理自泰芯 "TXW82x Low power consumption开发指南" V1. 0 (适with SDK v2. 7. 1. 7) , 实测数据基于泰芯电池摄像机开发板.

one, 先选 SDK and芯片

  • SDK: Low power consumption IPC 需要 2. 7. 1. 7 版本 (2. 7. 0. 7 不support) .
  • 芯片: 官方参数里标the「Low power consumption」the是 TXW828-C08FL, TXW828-E08FL, TXW828-E016FL, 选型见 TXW826 / 827 / 828 怎么选.
  • 参考方案: CUSTOMER_ID 9 (电池相机 1080P) , 另有 CUSTOMER_ID 7 (Low power consumption 720P IPC) .

two, three种休眠mode怎么选

mode 休眠时 Wi-Fi 唤醒后 唤醒方式 休眠Electric current参考
1 Wi-Fi 保活休眠 保持连接 从休眠点继续运行 远程唤醒 / IO / 定时 约 338μA
3 SRAM 保持休眠 断开 从休眠点继续运行 IO / 定时 约 91μA
5 RTC 休眠 断开 系统重启, 重新初始化 IO / 定时 约 43μA

Electric current数据是官方in电池摄像机开发板上, 4. 2V 供电, screen蔽环境下the测试参考, 你the板子要自己实测.

怎么选:

  • 要手机 App 随时远程唤醒看画面 (比如可视门铃) → mode 1.
  • 只需要按键, PIR 人体感应或定时唤醒, 又希望唤醒快 → mode 3.
  • 追o最长待机, 能接受唤醒后重启 → mode 5.

three, with开发板快速验证

电池摄像机开发板出厂就烧the Demo (Flash 被擦the就编译 CUSTOMER_ID 9 重新烧) :

  1. 电池port接 4. 2V 电源, 串到Electric current表或Power dissipation分析仪上; debugSerial port接computer, 波特率 921600.
  2. 长按底部 SW1 几秒开机, 看Serial port日志确认启动.
  3. Serial port输入下面the命令测 RTC 休眠:
AT+SLEEP=5, 80000, 23, 1

含义: mode 5 (RTC 休眠) , 80 秒后定时唤醒, 唤醒 IO 为 PB7 (下降沿, right应 SW1 按键) . 休眠期间Electric current应in 35~45μA, 按 SW1 或等 80 秒后唤醒.

开发板the SW1 按下后接通电源, 需要程序启动后自己控制电源开关脚来维持供电; 休眠期间也要保持这个脚the输出状态, 否则会把自己断电. 这one点设计自己the板子时同样要Look out.

four, 核心port

进入休眠

struct system_sleep_param args; 
os_memset (&args,  0,  sizeof (args) ) ; 
args. sleep_ms = 5000;                               // 5 秒后定时唤醒,  填 0 表示不定时唤醒
system_sleep (SYSTEM_SLEEP_TYPE_SRAM_ONLY,  &args) ;   // mode 3

system_sleep_param 里还可以配唤醒 IO:

字段 说明
sleep_ms 定时唤醒时长, 毫秒; 0 = 只靠 IO 唤醒
wkup_io_sel[6] 最more 6 路唤醒 IO (IO0~IO5) 选哪个引脚
wkup_io_en 使能掩码, bit0 right应 wkup_io_sel[0]
wkup_io_edge 边沿掩码: 0 = 上升沿 (芯片自动开下拉) , 1 = 下降沿 (自动开上拉)

唤醒 IO 优先with PA0~PA14, 这个范围 6 路唤醒源都能选到, 兼容性最好.

休眠时保持 IO 状态

进入休眠时, none特别声明the IO 会被复位, 防止浮空漏电. 电源使能, TF 卡电源, 功放使能这类休眠期间要保持电平the脚, 要with掩码声明:

dsleep_set_user_gioa (BIT (0)  | BIT (3) ) ;    // 休眠期间保持 PA0, PA3 原有状态

B~F 口right应 dsleep_set_user_giob () ~ dsleep_set_user_giof () .

休眠期间保存数据

休眠时只有常电 SRAM 区域the数据不会丢. 需要跨休眠保存the变量, with __dsleep_data 修饰:

__dsleep_data uint8 wake_count = 0; 

运行时动态申请with sys_sleepdata_request (SYSTEM_SLEEPDATA_ID_USER, size) . 只with SYSTEM_SLEEPDATA_ID_USER 这个 ID, 其他 ID 是 SDK 内部withthe.

休眠期间计时

休眠时 systick 停止计数 (日志时间戳不变) , 唤醒后 SDK 会补偿系统时间. 休眠流程里要计时, with常电域the RC 定时器 pmu_tmrao_get () , 再按校准后the RC 频率换算成毫秒.

three个 Hook: 不完全唤醒也能干活

Hook 什么时候调with 典型with途
wakeup_hook IO / 定时唤醒后立刻调with 唤醒过滤: 比如 PIR 触发 5 次才真正唤醒, 否则返回「继续休眠」, 避免干扰脉冲误唤醒
ready_hook 射频就绪后调with 主动发保活包, 周期性向服务器上报状态
rx_hook 收到 MAC 层数据包时调with 判断是不是有效the唤醒报文 (ininterrupt里执行, 要尽快返回)

wakeup_hook the返回value决定接下来怎么走: DSLEEP_ACTION_SLEEP_CONTINUE 放弃本次唤醒继续睡, DSLEEP_ACTION_SLEEP_EXIT 正常唤醒, DSLEEP_ACTION_DO_NOTHING 交给框架默认处理.

参考代码the远程唤醒检测是「收到任意 TCP 包就唤醒」. 量产产品应该再校验源 IP, 端口或报文内容, 否则网络上the杂包会频繁把设To prepare唤醒, 严重影响续航.

五, 把自己the模块接进Low power consumption流程

真实产品睡觉前, 要先把 TF 卡, 摄像头, ISP, 音频这些模块停掉; 醒来后再按顺序恢复. SDK the sdk/app/lowPower_app 框架帮你管这件事: 每个模块提供oneright suspend / resume 回调, Sign in成one个数组, 框架自动按顺序调with.

1. 确认ENGINEERING打开the CONFIG_SLEEP, 并且in wifi. c 里调withthe bgn_dsleep_init () .

2. 每个模块写 suspend / resume 回调: suspend 返回前要确认相关任务, DMA, interrupt都停the; resume 按初始化依赖恢复, 不要重复found任务. 成功返回 RET_OK.

3. 按上电初始化the顺序排数组:

static const struct lowPower_module_ops user_lowpower_modules[] = {
    {"power",    user_power_suspend,    user_power_resume,    {NULL,  NULL,  NULL,  NULL}}, 
    {"sensor",   user_sensor_suspend,   user_sensor_resume,   {&g_sensor,  &g_sensor_cfg,  NULL,  NULL}}, 
    {"service",  user_service_suspend,  user_service_resume,  {NULL,  NULL,  NULL,  NULL}}, 
}; 

框架规则: suspend 从数组末尾往前执行, resume 从前往后执行. 上面the数组睡前依次停 service → sensor → power, 醒后依次恢复 power → sensor → service. 某个模块 suspend 失败时, 框架会把已经停掉the模块恢复回来.

4. 业务模块都初始化完以后, Sign inone次:

lowpower_app_init (user_lowpower_modules,  ARRAY_SIZE (user_lowpower_modules) ) ; 

one个应with只调withone次, 再调with会清空之前the模块表.

5. 业务需要时调with system_sleep () , 框架会自动执行 suspend, 唤醒后自动调度 resume.

电池相机方案the模块表可以直接参考, 它Sign inthe 7 个模块: 电源前置, SD, MIPI, ISP, VPP, 音频, 电源后置.

执行顺序只看数组位置, and模块名字里the prev / post 无关. 设计新板子时, 按外围器件the上下电要o重新检查数组顺序.

六, 降power-consuming硬件要点

  • IO 唤醒电路: support电平唤醒, 按需o配上升沿或下降沿.
  • 外部 DCDC: 板子with外部 DCDC 给内核供电时, 可以调with dsleep_set_ext_dcdc (1) , 休眠期间关闭内部 LDO, 进one步降Low power consumption.
  • RTC 精度: 默认with内部 RC 计时; 需要更准the定时, 加 32. 768kHz 晶振, 并in bgn_dsleep_init the flags 里使能.
  • 外设断电: Sensor, TF 卡, 功放the电源最好都能with IO 控制关断, 并in休眠时保持关断状态.

相关阅读

do电池产品遇到Power dissipationproblem, 欢迎in社区Ask a question, 附上休眠mode, Electric current曲线and唤醒方式.

参考资料

0 Pieces of review

AI
Questions and answers

publish
problem