• CC26XX睡眠


    低功耗模式分为两种:1、掉电模式(shutdown),2、睡眠模式(sleep 或者 standby)

    1、睡眠模式

    即规格书中说的 Standby 模式,电流功耗 1.1uA,只有 RTC,RAM/CPU 保持运行

    int_fast16_t Power_sleep(uint_fast16_t sleepState)

    参数说明

    sleepState 目前只支持 PowerCC26XX_STANDBY

    示例:

    Power_sleep(PowerCC26XX_STANDBY);

    2、掉电模式

    只能通过外部中断唤醒,电流功耗 100nA

    int_fast16_t Power_shutdown(uint_fast16_t shutdownState, uint_fast32_t shutdownTime)

    参数说明

    shutdownState:没有使用

    shutdownTime:没有使用

    注意:

    调用该 API 时需要先禁用所有中断

    睡眠之前,需要调用函数PINCC26XX_setWakeup配置管脚唤醒

    示例:

    1. PIN_Config ButtonTableWakeUp[] = {
    2. CONFIG_PIN_BUTTON_0 | PIN_INPUT_EN | PIN_PULLUP | PINCC26XX_WAKEUP_NEGEDGE,
    3. PIN_TERMINATE /* Terminate list */
    4. };
    5. /* Configure DIO for wake up from shutdown */
    6. PINCC26XX_setWakeup(ButtonTableWakeUp);
    7. /* Go to shutdown */
    8. Power_shutdown(0, 0);

    3、注册监听电源状态

    int_fast16_t Power_registerNotify(Power_NotifyObj * pNotifyObj, uint_fast16_t eventTypes, Power_NotifyFxn notifyFxn, uintptr_t clientArg)

    参数说明

    pNotifyObj: 通知对象结构体

    eventTypes: 需要注册的事件类型

    notifyFxn: 回调函数

    clientArg: 回调函数的参数

    4、TIRTOS睡眠


    使能睡眠功能,通过TI图形化配置工具,选中Enable Policy,或者通过代码调用Power_enablePolicy/Power_disablePolicy来使能/禁止

    a、配置完成后系统自动生成以下代码

    1. const PowerCC26X2_Config PowerCC26X2_config = {
    2. .enablePolicy = true,
    3. .policyInitFxn = NULL,
    4. .policyFxn = PowerCC26XX_standbyPolicy,
    5. .calibrateFxn = PowerCC26XX_calibrate,
    6. .calibrateRCOSC_LF = true,
    7. .calibrateRCOSC_HF = true,
    8. .enableTCXOFxn = NULL
    9. };

    b、待机策略函数是 PowerCC26XX_standbyPolicy 也可以通过代码调用Power_setPolicy设置

    c、在Power_idleFunc函数会调用 PowerCC26XX_standbyPolicy (在Power_init函数已经把PowerCC26X2_config.policyFxn赋值给PowerCC26X2_module.policyFxn,而PowerCC26X2_config.policyFxn初始化时就赋值为PowerCC26XX_standbyPolicy)

    1. void Power_idleFunc()
    2. {
    3. if (PowerCC26X2_module.enablePolicy) {
    4. if (PowerCC26X2_module.policyFxn != NULL) {
    5. (*(PowerCC26X2_module.policyFxn))();
    6. }
    7. }
    8. }

     d、Power_idleFunc函数在空闲任务中被调用    

    1. #pragma location = ".const_ti_sysbios_knl_Idle_funcList__A"
    2. const __T1_ti_sysbios_knl_Idle_funcList ti_sysbios_knl_Idle_funcList__A[1] = {
    3. ((xdc_Void(*)(xdc_Void))(Power_idleFunc)), /* [0] */
    4. };

    e、睡眠策略函数 PowerCC26XX_standbyPolicy

    1. void PowerCC26XX_standbyPolicy(void)
    2. {
    3. bool justIdle = TRUE;
    4. uint32_t constraints;
    5. uint32_t ticks, time;
    6. /* disable interrupts */
    7. CPUcpsid();
    8. /* check operating conditions, optimally choose DCDC versus GLDO */
    9. SysCtrl_DCDC_VoltageConditionalControl();
    10. /* query the declared constraints */
    11. constraints = Power_getConstraintMask();
    12. /* do quick check to see if only WFI allowed; if yes, do it now */
    13. if ((constraints &
    14. ((1 << PowerCC26XX_DISALLOW_STANDBY) | (1 << PowerCC26XX_DISALLOW_IDLE))) ==
    15. ((1 << PowerCC26XX_DISALLOW_STANDBY) | (1 << PowerCC26XX_DISALLOW_IDLE))) {
    16. /* Flush any remaining log messages in the ITM */
    17. ITM_flush();
    18. PRCMSleep();
    19. /* Restore ITM settings */
    20. ITM_restore();
    21. }
    22. /*
    23. * check if any sleep modes are allowed for automatic activation
    24. */
    25. else {
    26. /* check if we are allowed to go to standby */
    27. if ((constraints & (1 << PowerCC26XX_DISALLOW_STANDBY)) == 0) {
    28. /*
    29. * Check how many ticks until the next scheduled wakeup. A value of
    30. * zero indicates a wakeup will occur as the current Clock tick
    31. * period expires; a very large value indicates a very large number
    32. * of Clock tick periods will occur before the next scheduled
    33. * wakeup.
    34. */
    35. ticks = Clock_getTicksUntilInterrupt();
    36. /* convert ticks to usec */
    37. time = ticks * Clock_tickPeriod;
    38. /* check if can go to STANDBY */
    39. if (time > Power_getTransitionLatency(PowerCC26XX_STANDBY,
    40. Power_TOTAL)) {
    41. /* schedule the wakeup event */
    42. ticks -= PowerCC26X2_WAKEDELAYSTANDBY / Clock_tickPeriod;
    43. Clock_setTimeout(Clock_handle((Clock_Struct *)&PowerCC26X2_module.clockObj), ticks);
    44. Clock_start(Clock_handle((Clock_Struct *)&PowerCC26X2_module.clockObj));
    45. /* Flush any remaining log messages in the ITM */
    46. ITM_flush();
    47. /* go to standby mode */
    48. Power_sleep(PowerCC26XX_STANDBY);
    49. /* Restore ITM settings */
    50. ITM_restore();
    51. Clock_stop(Clock_handle((Clock_Struct *)&PowerCC26X2_module.clockObj));
    52. justIdle = FALSE;
    53. }
    54. }
    55. /* idle if allowed */
    56. if (justIdle) {
    57. /* Flush any remaining log messages in the ITM */
    58. ITM_flush();
    59. /*
    60. * Power off the CPU domain; VIMS will power down if SYSBUS is
    61. * powered down, and SYSBUS will power down if there are no
    62. * dependencies
    63. * NOTE: if radio driver is active it must force SYSBUS enable to
    64. * allow access to the bus and SRAM
    65. */
    66. if ((constraints & (1 << PowerCC26XX_DISALLOW_IDLE)) == 0) {
    67. uint32_t modeVIMS;
    68. /* 1. Get the current VIMS mode */
    69. do {
    70. modeVIMS = VIMSModeGet(VIMS_BASE);
    71. } while (modeVIMS == VIMS_MODE_CHANGING);
    72. /* 2. Configure flash to remain on in IDLE or not and keep
    73. * VIMS powered on if it is configured as GPRAM
    74. * 3. Always keep cache retention ON in IDLE
    75. * 4. Turn off the CPU power domain
    76. * 5. Ensure any possible outstanding AON writes complete
    77. * 6. Enter IDLE
    78. */
    79. if ((constraints & (1 << PowerCC26XX_NEED_FLASH_IN_IDLE)) ||
    80. (modeVIMS == VIMS_MODE_DISABLED)) {
    81. SysCtrlIdle(VIMS_ON_BUS_ON_MODE);
    82. }
    83. else {
    84. SysCtrlIdle(VIMS_ON_CPU_ON_MODE);
    85. }
    86. /* 7. Make sure MCU and AON are in sync after wakeup */
    87. SysCtrlAonUpdate();
    88. }
    89. else {
    90. PRCMSleep();
    91. }
    92. /* Restore ITM settings */
    93. ITM_restore();
    94. }
    95. }
    96. /* re-enable interrupts */
    97. CPUcpsie();
    98. }

    任务空闲时,程序会调用PowerCC26XX_standbyPolicy,根据当前系统的状态进入不同的睡眠模式,并根据最短的那个任务调度时间设置定时唤醒。

    参考官方文档“Power_Management.pdf”

  • 相关阅读:
    java web 前置知识——Servlet(一)
    什么是网络API以及用例
    Pytorch学习笔记(二)官方60min入门教程之自动微分
    数据库——知识1
    深入理解JVM虚拟机第二十三篇:详解JVM当中的栈顶缓存技术
    y147.第八章 Servless和Knative从入门到精通 -- Event Sources和Sinks(十一)
    Windows下jupyter notebook配置默认路径及配置默认启动chrome浏览器
    01|JVM类加载机制
    【Go】用 DBeaver、db browser 和 SqlCipher 读取 SqlCipher 数据库
    多普勒流速仪的功能作用是什么?
  • 原文地址:https://blog.csdn.net/dear_Wally/article/details/126937925