• 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 » dynamic arrays in flash, .sysmem warning
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?
  • InstaSPIN Simulation Tool
  • Product Folder: F28069F, F28068F, F28062F, F28068M, F28069M
  • User’s Guide
  • Technical User’s Manual
  • Tools
  • Forums

    dynamic arrays in flash, .sysmem warning

    This question is answered
    Toby Mole
    Posted by Toby Mole
    on Apr 03 2012 09:14 AM
    Expert1740 points

    Hi Folks

    I am trying to create a dynamic array in a function and  pass a pointer to it to another function.

    However when I run malloc() the compiler gives two warnings:

      creating ".sysmem" section with default size of 0x400; use the -heap option to change the default size

      function declared implicitly

    both of which refer to the malloc instruction which is as below:

      sciFifoTxBuf = (Uint16*) malloc(sizeof(Uint16));

    Im guessing that maybe there is some different way to achieve this functionality in flash in CCS?

    Appreciate a point in the right direction

    Ta

    F28027 C2000 flash CCS dynamic array
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Trey German
      Posted by Trey German
      on Apr 03 2012 13:04 PM
      Verified Answer
      Verified by Toby Mole
      Genius14800 points

      Hi Toby,

      For the first warning, take a look at you linker command file.  Do you have a .sysmem section defined and linked into RAM?  If not take a look at the linker command files provided in controlsuite and try using one that does.

      The second warning you are getting because you aren't including the right header file.  Try including stdlib.h.

      Keep in mind that dynamically allocated memory must be in RAM, not flash.

      Regards,

      Trey

      Trey German

      C2000 Applications

      If a post answers your question, please mark it with the "verify answer" button.
      Visit these helpful C2000 Links!
      C2000 TI Wiki Pages
      TI Forum Sitemap
      ControlSUITE
      C2000 Getting Started
      CLA FAQs
      Workshop Material!
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andy Neil
      Posted by Andy Neil
      on Apr 03 2012 13:35 PM
      Guru32055 points

      Trey German
      Keep in mind that dynamically allocated memory must be in RAM, not flash.

      Also keep in mind that dynamic memory allocation is often best avoided in embedded systems.

      Why, specifically, do you think that you need dynamic allocation?

       

      Dynamic memory allocation - just say NO!
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Trey German
      Posted by Trey German
      on Apr 03 2012 13:41 PM
      Genius14800 points

      ++ to Andy's comment!!!

      Trey German

      C2000 Applications

      If a post answers your question, please mark it with the "verify answer" button.
      Visit these helpful C2000 Links!
      C2000 TI Wiki Pages
      TI Forum Sitemap
      ControlSUITE
      C2000 Getting Started
      CLA FAQs
      Workshop Material!
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Toby Mole
      Posted by Toby Mole
      on Apr 03 2012 14:15 PM
      Expert1740 points

      Hi Folks

      Thanks for the comments. The reason for the dynamically allocated memory is for reading in data received on communications peripherals, in this case the SCI.

      Information transmitted on the SCI could be of any length, and I plan, at a later stage, to implement an SCPI parser on the device to pass instructions to it from a parent control system, so the data string coming in could again be very short or relatively very long.

      While i can see that there needs to be a limit on the amount of memory allowed to be dynamically allocated for a specific task for only the short time that the task requires it, it would be a waste to set a some long length as the maximum number of characters and permanently reserve that space in memory, thus for embedded systems that have less memory than is available to computer applications, I would have thought this approach to be the more desirable one...

      Though I guess if thats the way it should be done, then thats the way it should be done.

      Trey, f I was to use dynamically allocated memory how would I ensure that it be allocated in RAM instead of flash?

      Thanks

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andy Neil
      Posted by Andy Neil
      on Apr 03 2012 14:52 PM
      Guru32055 points

      Toby Mole
      it would be a waste to set a some long length as the maximum number of characters and permanently reserve that space in memory

      But that is exactly what you have to do in order to support dynamic allocation - it is called The Heap!!

      And, not only do you have to reserve that memory, but you also make less efficient use of it - due to the overheads of manging the dynamic allocation.

      And you add the issues of having to deal with fragmentation, etc...

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Derek Belle
      Posted by Derek Belle
      on Jul 04 2012 21:41 PM
      Intellectual495 points

      On the issue of fragmentation: when the CPU is reset does that act as an indirect "defragmentation" of that memory location since the heap is located in RAM?

      Is this a true statement?"

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Trey German
      Posted by Trey German
      on Jul 05 2012 10:15 AM
      Genius14800 points

      Toby,

      Memory allocation is handled in the linker command files (*.cmd).  I'm not sure off the top of my head which section the heap is placed in, but the assembly language tools user guide could probably tell ya.

      Trey

      Trey German

      C2000 Applications

      If a post answers your question, please mark it with the "verify answer" button.
      Visit these helpful C2000 Links!
      C2000 TI Wiki Pages
      TI Forum Sitemap
      ControlSUITE
      C2000 Getting Started
      CLA FAQs
      Workshop Material!
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Trey German
      Posted by Trey German
      on Jul 05 2012 10:17 AM
      Genius14800 points

      Derek,

      Yes, a CPU reset would effectively defragment the RAM as all of the variables that kept track of allocation would be reinitialized.  Data may still be present in RAM, but it won't be usable because the program execution wouldn't be aware of it.

      Trey

      Trey German

      C2000 Applications

      If a post answers your question, please mark it with the "verify answer" button.
      Visit these helpful C2000 Links!
      C2000 TI Wiki Pages
      TI Forum Sitemap
      ControlSUITE
      C2000 Getting Started
      CLA FAQs
      Workshop Material!
      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