When is PWR_AllowDeviceToSleep and PWR_DisallowDeviceToSleep called?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

When is PWR_AllowDeviceToSleep and PWR_DisallowDeviceToSleep called?

947 Views
Tome-mbedded
Contributor II

hello everyone,

In 1246 project function vAttemptToSleep (), when u16ActivityCount = = u8ValNumberOfNonSleepPreventingTimers will into the sleep state, I don't know where is this mLPMFlag assignment; I don't know when PWR_AllowDeviceToSleep and PWR_DisallowDeviceToSleep are called

捕获2.PNG

捕获3.PNG

When are these two functions called? I can't tell from the log print where it was called。

捕获4.PNG捕获5.PNG

0 Kudos
Reply
8 Replies

899 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Tome-mbedded 

1.

extern uint8_t mLPMFlag;

is controlled by the Macro:

APP_LOW_POWER_API

K32W148EVK

Please check and make sure the first one is defined and the second one is not defined.

2.I did search in the V2008 JN-AN-1246 source code, but I didn't find these 2 functions.

Can you please let  me know the file and file path of these 2 functions?

Can you please let me know where did you download the JN-AN-1246.zip?

Best regards,

Christine.

Tags (1)
0 Kudos
Reply

893 Views
Tome-mbedded
Contributor II

hi @Christine_Li 

thanks for your reply.

I'm using the JN5189 chip.Below is the download link for the 1246sensor project.  I downloaded it earlier, version 2007.

https://www.nxp.com.cn/products/wireless-connectivity/thread/jn5189-88-t-high-performance-and-ultra-...

Tomembedded_0-1709050901063.png

1、The mLPMFlag variable is defined in JN5189DK6

The PWR_DisallowDeviceToSleep and PWR_AllowDeviceToSleep functions are also defined in JN5189DK6.Here are their paths

JN5189DK6\middleware\wireless\framework\LowPower\Source\jn5189dk6\PWR.c

Tomembedded_1-1709051304713.png

The APP LOW POWER API is defined in the makefile

Tomembedded_2-1709051404195.png

2、I don't know when u16ActivityCount u8ValNumberOfNonSleepPreventingTimers equal, they are equal to to sleep. But my sensor codes, sometimes they're not equal, so they don't go to sleep. What's the reason?

Tomembedded_3-1709051972101.png

 

 

0 Kudos
Reply

877 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi @Tome-mbedded 

Thanks for your reply.

There is another condition to enter sleep mode.

    if ((u16ActivityCount == u8ValNumberOfNonSleepPreventingTimers) &&
        (0 == u8ValNumberOfTimersTaskTimers))

 

When the both conditions meet, then can enter to sleep.

And you can also print more logs to see whether is equal.

Best regards,

Christine.

Tags (1)
0 Kudos
Reply

793 Views
Tome-mbedded
Contributor II

hello,

Sorry for the late reply

The second condition is set up (0 = = u8ValNumberOfTimersTaskTimers), but the first condition is not set up (

(u16ActivityCount == u8ValNumberOfNonSleepPreventingTimers))

Tomembedded_0-1709709454684.png

Sometimes the Activity is equal to 1, it equals the u8ValNumberOfNonSleepPreventingTimers, it can sleep. What is the reason for this?

0 Kudos
Reply

784 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Tome-mbedded 

Are you sure it enters this if condition?

Can you please set bDbug to True or add some logs here to double confirm it enters this "if" condition?

if ((u16ActivityCount == u8ValNumberOfNonSleepPreventingTimers) &&
        (0 == u8ValNumberOfTimersTaskTimers))
    {
        if (bDebug) DBG_vPrintf(TRACE_SLEEP_HANDLER, ", SLEEP YES");

Best regards,

Christine.

 

Tags (1)
0 Kudos
Reply

780 Views
Tome-mbedded
Contributor II

thank you,

Can't go to the if condition, because u16ActivityCount U8ValNumberOfNonSleepPreventingTimers is not equal. u16ActivityCount Where does the value of this variable come from? The routine u8ValNumberOfNonSleepPreventingTimers this value is 1 or 2, but print u16ActivityCount this value may be greater than 3. So it can't be equal u8ValNumberOfNonSleepPreventingTimers. So  can't go into the if condition

Tomembedded_0-1709713847766.png

 

0 Kudos
Reply

761 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Tome-mbedded 

u16ActivityCount Where does the value of this variable come from? 

==> Please see below for the source of u16ActivityCount.

 

#ifdef APP_LOW_POWER_API
#ifndef K32W148EVK
    u16ActivityCount = mLPMFlag;
#else
    u16ActivityCount = PWRM_u16GetActivityCount();
#endif
#else
    u16ActivityCount = PWRM_u16GetActivityCount();
#endif

So you need to check the MACRO: APP_LOW_POWER_API and K32W148EVK.

If you are not sure, you can add some wrong method, and try to compile to see whether have compile errors.

And for your information: PWRM_u16GetActivityCount() function is defined in our internal SDK. There is no source code available for us. We only provide this API, you can check docs/wireless/Zigbee/JN-UG-3133-Core-Utilities.pdf in your SDK directory to see explanation of this API.

And mLPMFlag is defined in the middleware/wireless/framework/LowPower/Source/jn5189dk6/PWR.c

uint8_t mLPMFlag               = gAllowDeviceToSleep_c;

Then

middleware/wireless/framework/LowPower/Interface/jn5189dk6/PWR_Interface.h

#ifndef gAllowDeviceToSleep_c
#define gAllowDeviceToSleep_c 0
#endif

 

Best regards,

Christine.

0 Kudos
Reply

797 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Tome-mbedded 

Anything else I can do for you on this case?

 

Best regards,

Christine.

0 Kudos
Reply