关于2541的唤醒
我现在使用2541的demo工程,当设为省电模式时
按键后30秒设备可查找
我们需要的是没有按键的省电模式,比如advertise 100ms,休眠1秒
我做如下的初始化:
uint8 initial_advertising_enable = TRUE;
// By setting this to zero, the device will go into the waiting state after
// being discoverable for 30.72 second, and will not being advertising again
// until the enabler is set back to TRUE
uint16 gapRole_AdvertOffTime = 1000;
...(其他初始化使用默认)
// Set fast advertising interval for user-initiated connections (仿照按键响应代码)
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, DEFAULT_FAST_ADV_INTERVAL );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, DEFAULT_FAST_ADV_INTERVAL );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_MIN, 100 );
修改了osal_pwrmgr_powerconserve函数使上电后一分钟才能休眠,让advertise有机会执行:
void osal_pwrmgr_powerconserve( void )
{
uint32 next;
halIntState_t intState;
// Should we even look into power conservation
if ( pwrmgr_attribute.pwrmgr_device != PWRMGR_ALWAYS_ON && osal_GetSystemClock()>60000)
{
...
现在的问题是,休眠后无法自动唤醒发advertise,请问应该如何解决?
你的advertise关闭跟睡眠关系不大
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL
我如果把POWER_SAVING宏去掉,就能够一直advertise
重点是要这样: advertise 100ms,休眠1s,advertise 100ms,休眠1s...
如下配置
gapRole_AdvertOffTime = 1000;
GAP_SetParamValue( TGAP_GEN_DISC_ADV_MIN, 100 );
我的理解,就是停发adv 1秒,然后又会自动重发
我看了在halsleep函数中,会检查各定时器,换算为SleepTimer定时唤醒
既然配置了要重发的定时任务,是否就应该自动唤醒?
我现在跟踪调试,发现demo中的PM2模式似乎唤不醒芯片,在halSleepTimerIsr中设断点没有拦截到
在CC2541的文档中看到:
The Sleep Timer is also used to maintain timing in Timer 2 when entering power mode
PM1 or PM2.
When Timer 2 is used together
with the Sleep Timer, the timing function is provided even when the system enters low-power modes PM1
and PM2.
跟Timer2一起用会影响到Sleep Timer的唤醒功能吗
串口打印调试发现,呆在这句:
if ( LL_PowerOffReq(halPwrMgtMode) == LL_SLEEP_REQUEST_ALLOWED )
停止运行时,Dissasembly窗口每次都是在llStopTimer2函数
经定位,是我们这边硬件设计有所不同所致
谢谢