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.

how to change from PM2 mode to active mode?

Other Parts Discussed in Thread: CC2541

a modified SimpleBLEPeripheral project for CC2541  with Ifrared control using Timer3 and Timer1 for 40kHz carrier modulation code, project works fine with 

osal_pwrmgr_device( PWRMGR_ALWAYS_ON );

to save power, change it to

osal_pwrmgr_device( PWRMGR_BATTERY );

but it seems to traped in PM2 and never returned to active mode, though there's periodic events shows up as expectd, but the 32k clock in PM2 mode seems to change the carrier  frequency and the signal did not work.

how to exit PM2 before sending IR control signal?

  • Are you using a 32kHz crystal or 32k-ROSC as source for the sleep timer?

    There is an OSAL API function osal_pwrmgr_task_state() which can be called from any task to change the task power state. There are two task power states: PWRMGR_HOLD and PWRMGR_CONSERVE. By default all tasks start in PWRMGR_CONSERVE and if at least one task switches its state to PWRMGR_HOLD then the power manager will be disable until all task states are CONSERVE again.

    Try using this function as a wrapper around your IR control to hold the power management. You can find more info on the function in "OSAL API.pdf" which is located in the Documents/osal folder of the BLE stack download.

    -Matt

  • there is a 32K crystal, and the CLKCONSTA.OSC32K is 0, so it must use the 32kHz crystal.

    as the keyfob project uses osal_pwrmgr_device() so our project use it too.  it make no difference changing osal_pwrmgr_device( PWRMGR_ALWAYS_ON ) to osal_pwrmgr_task_state( IRG_TaskId, PWRMGR_HOLD );

    and change osal_pwrmgr_device( PWRMGR_BATTERY ) to osal_pwrmgr_task_state( IRG_TaskId, PWRMGR_CONSERVE )

    maybe the 32MHz clock not stable after change from PM2 to active. and the debug result showed once the system changed to PM2 mode, it stays in PM2 mode. does the period event use a sleep timer interrupt to bring the system back to active mode from PM2? 

  • The OSAL will put the device into PM2 at the end of osal_run_system() if there are no events currently pending. It will set the sleep timer interrupt to occur based on the timing of the next event in the system. So the answer is yes the sleep timer is used to wake up the system from PM2 to active mode. Then once there are no more events to be processed the OSAL will again put the device into PM2 from active mode.

    The Timer1 and Timer3 should be disabled in PM2 so if you are seeing any IR activity then you are entering active mode.

    When you say the signal did not work does that mean you are unable to detect any IR signal or that the IR signal you are detecting is of the wrong carrier frequency?

    If you are detecting no signal (or maybe just a very short burst of a signal when the processor goes to active mode), what I suspect you're seeing is that PM2 is disabling Timers1 and 3 so no IR signal is being generated constantly as it might have been in your original applciation that was always in active mode.

    If you are getting an IR signal but just of the wrong carrier fequency it may be that the 32MHz has not stabilized. Can you determine the carrier frequency of the signal if that is the case?

     

     

  • the IR app used CLKCONCMD.TICKSPD to set global clock prescaler for 8MHz clock, but the pwrmgr subsystem of BLE stack(ref: hal_sleep.c) use CLKCONCMD.TICKSPD to set global clock prescaler for 32MHz clock. so that each time wake up from PM2, the IR's carrier frequency is 4 times of the expected .

    resoved by only using timer's local clock prescaler.