This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540在进入PM3后,怎么正确唤醒

Other Parts Discussed in Thread: CC2540

各位大大们好:

    请问,在进入PM3后,已经可以通过按键重新唤醒MCU,但是,该怎么才能使射频正常工作啊~`(*∩_∩*)′

HAL_ISR_FUNCTION( halPort2Isr, P2INT_VECTOR )
{
  HAL_ENTER_ISR();
  uint8 value;
  if( P2IFG & 0x01 )
  {
    P2IFG &= ~BV(0);
    value = TRUE;
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof(uint8), &value); //开启广播
  }
  else
  {
    P2IFG = 0;
  }
  CLEAR_SLEEP_MODE();
  HAL_EXIT_ISR();
}

这是我P2.0中断的代码,在中断中,我恢复了 CC2540 的广播使能,发现能成功进入中断,但是运行完开启广播那一句之后,广播并没有开启。所以想问一下各位大大,我该怎么做才行,谢谢~`(*∩_∩*)′

  • Bob,

    最好不要再这里直接调用应用层的这个函数。

    建议你可以参考keyfob 工程里面的按键IO 中断触发唤醒PM3 直接进入广播的代码,有现成的。

  • Yan,

    if( gapProfileState != GAPROLE_CONNECTED )
    {
    uint8 current_adv_enabled_status;
    uint8 new_adv_enabled_status;

    //Find the current GAP advertisement status
    GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &current_adv_enabled_status );

    if( current_adv_enabled_status == FALSE )
    {
    new_adv_enabled_status = TRUE;
    }
    else
    {
    new_adv_enabled_status = FALSE;
    }

    //change the GAP advertisement status to opposite of current status
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );
    }

    这段代码可以唤醒PM2状态么?还有怎么能让蓝牙进入PM2。是用这个么osal_pwrmgr_device( PWRMGR_BATTERY );?还有我打开PowerSave之后为什么之前能给串口发送的数据现在貌似全都发不出去了?

  • 我认为应该可以。你的那个问题,我想如果想是用那些外设设备,必须,将电池模式调成

    osal_pwrmgr_device( PWRMGR_ALWAYS_ON );,不然设备休眠会影响外设工作。

    还有,按照TI员工的回复,我认为,从中断中让设备进入正常状态的步骤应该是:

    1.在中断函数中添加一个定时器任务:

    XX_ISR( void )
    {
    	//其它函数
    	..
    	
    	//使能一个定时器任务
    	osal_set_event( simpleBLEPeripheral_TaskID, _My_DEVICE_START );
    }

    2.然后在定时器时间轮询函数" SimpleBLEPeripheral_ProcessEvent() "中添加具体的业务逻辑,调电池模式啊,开广播啊啥的:

    uint16 SimpleBLEPeripheral_ProcessEvent( uint8 task_id, uint16 events )
    {
    	//其它事件轮询函数
    	//..
    	
    	//中断事件的定时器任务
    	if( events & _My_ISR_EVENT )
    	{
    		osal_pwrmgr_device( PWRMGR_BATTERY );
    		GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, 1, TRUE );
    		
    		return (events ^ _My_ISR_EVENT )
    	}
    }