• 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 » Microcontrollers » C2000™ Microcontrollers » C2000 32-bit Microcontrollers Forum » Delay Program -28335
Share
C2000™ Microcontrollers
  • Forums
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
C2000 Resources
  • Product Folder
  • C2000 Training Portal
  • C2000 Technical Training Catalog
  • C2000 Datasheets, App Notes, User Guides
  • C2000 Hardware Design Kits
  • controlSUITE for C2000 Software Library


  • InstaSPIN Resources
  • What is InstaSPIN?
  • Videos and Support


  • InstaSPIN-FOC and InstaSPIN-MOTION Resources
  • What is InstaSPIN-FOC?
  • What is InstaSPIN-MOTION?
  • Product Folder: F28069F, F28068F, F28062F, F28068M, F28069M
  • User’s Guide
  • Technical User’s Manual
  • Tools
  • Forums

    Delay Program -28335

    • Edwin Krasser
      Posted by Edwin Krasser
      on Sep 16 2011 03:58 AM
      Expert2220 points

      Hi!

      What's the variable type of number_of_microseconds? It must be long int or unsigned long int. Otherwise the 150*number_of_microseconds multiplication is a short int multiplication giving a wrong result. I tested it and I got ticks_required=4294959968 when using int as data type. With a long int data type it worked fine (just tested on a f28335).

      Regards,
      Edwin Krasser

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Julian Woloszczuk
      Posted by Julian Woloszczuk
      on Sep 16 2011 04:09 AM
      Intellectual445 points

      It's a Uint32. My device is a 2812.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Julian Woloszczuk
      Posted by Julian Woloszczuk
      on Sep 16 2011 04:16 AM
      Intellectual445 points

      A bit more info.   Using a figure of 10,000 microseconds, the 'stop_point' ends up as  4293467295, or 0xFFE9 1C9F. With this value, the higher 16-bits are being considered.  Tests with lower delays end up with 'stop_point' figures that leave the higher 16-bits as 0xFFFF. This may be something to do with the problem.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Edwin Krasser
      Posted by Edwin Krasser
      on Sep 16 2011 04:45 AM
      Expert2220 points

      I do not think that the 16-bit and 0xFFFF matter. You told that it worked with 1000 us wait time (150000 ticks, stop time will be 0xFFFD B60F). I do not know what else is running in your software, but the problem should derive from somewhere else (Watchdog? ISRs? Other functions accessing CPU timer 0? DSP-BIOS?).

      Regards,
      Edwin Krasser

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Julian Woloszczuk
      Posted by Julian Woloszczuk
      on Sep 16 2011 04:49 AM
      Intellectual445 points

      Yes, you're right with the figures - my mistake!   I'll take a look and see what else might be mangling things.  Thanks for your help so far!

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Arash Khoshkbar Sadigh
      Posted by Arash Khoshkbar Sadigh
      on Apr 06 2012 12:27 PM
      Prodigy40 points

      Dear all

      I add the following line in my code.

      #define DELAY_US(A)  DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) / 5.0L)

      When I want to build my project there is an error that "CPU_RATE" is undefined. However, the DSP2833x_Examples.h is included in my project and when I press Ctrl and click on "CPU_RATE", it directs me to to line "#define CPU_RATE    6.667L   // for a 150MHz CPU clock speed (SYSCLKOUT)" in file "DSP2833x_Examples.h" which means for me that "DSP2833x_Examples.h" is linked to my project. If I replace the "CPU_RATE" with "6.667L", there is not error. What is the problem?

      Second problem, as I said if I replace the "CPU_RATE" with "6.667L", my code doesn't have any error. But if I use "DELAY_US(1000000)" in my code, the delay is not working any more but if I use "DSP28x_usDelay(1000000)", delay works. 

      Can you please help me

      Arash

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Arash Khoshkbar Sadigh
      Posted by Arash Khoshkbar Sadigh
      on Apr 06 2012 18:33 PM
      Prodigy40 points

      Hi Lori

      I add the following line in my code.

      #define DELAY_US(A)  DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) / 5.0L)

      When I want to build my project there is an error that "CPU_RATE" is undefined. However, theDSP2833x_Examples.h is included in my project and when I press Ctrl and click on "CPU_RATE", it directs me to to line "#define CPU_RATE    6.667L   // for a 150MHz CPU clock speed (SYSCLKOUT)" in file "DSP2833x_Examples.h" which means for me that "DSP2833x_Examples.h" is linked to my project. If I replace the "CPU_RATE" with "6.667L", there is not error. What is the problem?

      Second problem, as I said if I replace the "CPU_RATE" with "6.667L", my code doesn't have any error. But if I use "DELAY_US(1000000)" in my code, the delay is not working any more but if I use "DSP28x_usDelay(1000000)", delay works. 

      Can you please help me?

      Arash

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Edwin Krasser
      Posted by Edwin Krasser
      on Apr 16 2012 00:44 AM
      Expert2220 points

      Hi,

      as I already wrote in this thread: I strongly recommend not to use such delay loops because these loops do not have an exact wait time. It's better to use the 32 bit CPU timer (initialize it just after startup) und wait for a given number of ticks. That's exact, even if interrupts occur during waiting.

      Best regards,
      Edwin Krasser

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    12
    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