• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Low Power RF & Wireless Connectivity » Low Power RF Bluetooth® Low Energy & ANT Forum » SDK V1.2.1 hal_sleep.c halSleep() Bug?
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

SDK V1.2.1 hal_sleep.c halSleep() Bug?

SDK V1.2.1 hal_sleep.c halSleep() Bug?

This question is answered
Eng351
Posted by Eng351
on Aug 01 2012 13:30 PM
Genius3130 points

I am having some issues with the latest SDK hal_sleep.c halSleep( uint32 osal_timeout ) function:

With the RF disabled, theOSAL is passing in a wakeup time of 30,000 (30s), but it is waking up every 2.00s (verified by scope).

I debugged halSleep() and found that the code which calculates the number of 32.768kHz cycles to sleep for is returning the wrong number - 0x0000FFFF which is causing the exact 2s wakeup.

The following code is where the problem happens (In the previous step osal_timeout is 30,000 as expected):

// get next OSAL timer expiration and convert to 32kHz units
// Note: Could be early by one 32kHz timer tick due to rounding.
timeout = llDivide31By16To16( (uint32)osal_timeout*4096, 125 );

After this line, timeout = 4294901885 (0xFFFF007D). Then:

// only need the quotient
timeout >>= 16;

After this line, timeout = 65535 (0x0000FFFF) (as expected from above), but the result should be 983040 (0x000F0000).

Has anyone seen this before? I have tried with compiler optimization on and off but this makes no difference.

Help please

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Eng351
    Posted by Eng351
    on Aug 01 2012 13:45 PM
    Genius3130 points

    Further to this, simply, max possible value of timeout = 0xFFFFFFFF, so max value after timeout >>= 16 is 0xFFFF i.e. 2s

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Eng351
    Posted by Eng351
    on Aug 07 2012 13:49 PM
    Genius3130 points

    Any answers from TI on this? Is this a bug or a feature?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Joakim Lindh
    Posted by Joakim Lindh
    on Aug 08 2012 01:32 AM
    Verified Answer
    Verified by Per H
    Genius13370 points

    Hi,

    Good catch, it is a bug which will we fixed in the next stack release. In the meantime you can change the timeout value as follows:

    timeout = HAL_SLEEP_MS_TO_32KHZ( osal_timeout );

    Best Regards

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Eng351
    Posted by Eng351
    on Aug 08 2012 13:40 PM
    Verified Answer
    Verified by Eng351
    Genius3130 points

    Thanks Nick, have added a work around.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Patrick Rennhard
    Posted by Patrick Rennhard
    on Oct 05 2012 08:26 AM
    Prodigy10 points

    For me

    timeout = HAL_SLEEP_MS_TO_32KHZ( osal_timeout );

    solves only the issue for periodic events.

    Setup: Advertisment every 5 seconds

     The function: LL_TimeToNextRfEvent( &sleepTimer, &llTimeout );  returns: first call: 65535,  second call: 65535, third call: 32972

    The result should be the sum of those three. So what happens is, it will wake up after 2 seconds with the wakeForRF flag set to TRUE and won't enter sleep mode until the RF event 3 seconds later.

    Has anyone seen this before? Is there a workaround to calculate the real time for the next RF Event?

    Best regards

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Szer Ming Lee
    Posted by Szer Ming Lee
    on May 22 2013 08:31 AM
    Prodigy40 points

    Hi, 

    We are seeing exactly the behaviour described even after fixing the timeout calculation as recommended. We have out advertisement set at 10s, we see the device wake up after 2 seconds and then will not return back to sleep until the next advertisement.

    Thanks

    Szer Ming

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Graham Lodge
    Posted by Graham Lodge
    on May 28 2013 10:49 AM
    Prodigy60 points

    Further to Szer Ming's comment: after fixing the timeout calculation, if we turn off advertising activity (no radio events scheduled), and set an application timer to fire after some long interval (for example 100 seconds) the CPU still wakes every 2 seconds.  The application event fires correctly after 100 seconds but all those extra unnecessary wake ups (they require >~1ms each) eat into the DC power budget.

    What does the function LL_TimeToNextRfEvent return when there is no radio event scheduled?  I'm not able to find any documentation that tells me how the 2 return parameters behave.

    Is this behaviour fixed in v1.3?  Or is there a way to get this working correctly in v1.21.  We would rather get a workaround for v1.2.1 if that's possible.

     

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use