主题中讨论的其他器件:CC2533、 Z-STACK、 RemoTI
工具与软件:
CC2530和 CC2533用户指南包含以下文本。
当操作在除 PM3之外的所有功耗模式时、睡眠定时器运行。 睡眠定时器的值
不会保留在 PM3中。 从 PM1或 PM2返回时(此时系统时钟关闭)
直到32kHz 时钟的正边沿出现之前、ST2:ST1:ST0中的睡眠定时器值不是最新的
在系统时钟重新启动后检测到。 为确保读取更新的值、请等待正转换
在32kHz 时钟上运行。 CLK32K 位、在读取睡眠计时器值之前。
这表示我应该编写代码以确保 SLEEPSTA 正常运行。 CLK32K!=0之后再读取 ST0 (或等待下一个上升沿、这将等待 SLEEPSTA。 设置为1、然后设置为0、再设置为1、以获得下一个上升沿)。
Z-Stack 3.02中面向 CC2530EB 的代码中没有该等待。 是否需要等待?
void halSleepSetTimer(uint32 timeout)
{
uint32 ticks;
/* read the sleep timer; ST0 must be read first */
((uint8 *) &ticks)[UINT32_NDX0] = ST0;
((uint8 *) &ticks)[UINT32_NDX1] = ST1;
((uint8 *) &ticks)[UINT32_NDX2] = ST2;
((uint8 *) &ticks)[UINT32_NDX3] = 0;
/* Compute sleep timer compare value. The ratio of 32 kHz ticks to 320 usec ticks
* is 32768/3125 = 10.48576. This is nearly 671/64 = 10.484375.
*/
ticks += (timeout * 671) / 64;
/* subtract the processing time spent in function halSleep() */
ticks -= HAL_SLEEP_ADJ_TICKS;
/* set sleep timer compare; ST0 must be written last */
ST2 = ((uint8 *) &ticks)[UINT32_NDX2];
ST1 = ((uint8 *) &ticks)[UINT32_NDX1];
ST0 = ((uint8 *) &ticks)[UINT32_NDX0];
}
与此类似、用户指南中 的状态为等待至 STLOAD。 在 wring 到 ST2之前、LDRDY 为1。 上面的代码没有这么做。 但是、用于 RemoTI 1.4.0中 CC2533EB 的宏在设置睡眠计时器寄存器后等待。
#define HAL_SLEEP_ST_SET(STCNT) st ( \
/* Set the sleep timer compare; ST0 must be written last. */\
ST2 = ((uint8 *) &(STCNT))[2]; \
ST1 = ((uint8 *) &(STCNT))[1]; \
ST0 = ((uint8 *) &(STCNT))[0]; \
while (!(STLOAD & LDRDY)); /* Wait for the sleep timer to load. */\
)
哪个版本(用户指南、Z-Stack 或 RemoTI)正确或者它很重要?