• 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 » Concerto compiler data/variable sizes
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
  • Concerto compiler data/variable sizes

    Concerto compiler data/variable sizes

    This question is answered
    Ronaldo Pace
    Posted by Ronaldo Pace
    on Apr 11 2012 08:34 AM
    Intellectual875 points

    hi,

    I'm programming my Concerto controller and I've just stumble across a part that I can't seem to find relevant documentation.

    Within my code I'm implementing the same functionality as seen in the RAM_management_m3 and RAM_management_C28 examples.
    Basically M3 writes to Shared S0 and C28 writes to Shared S3, and one read where the other is writing. Great, it's working and I can see the data coming and going, but I'm having problems regarding different variables sizes.

    On the mentioned examples it is used int for the M3 and long int for C28 which means it's 32 bits for each core.

    But what about other variable types? Where can I  find a table showing data types and size in bits for each core?

    concerto f28m35 data variable size core shared ram int long bit byte
    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 11 2012 09:01 AM
      Verified Answer
      Verified by Ronaldo Pace
      Genius14470 points

      Ronaldo,

      Such a table doesn't exist, but I'll do you one better.

      C99 defines standard integer types which are the same across all platforms.  Using these variables helps to make code portable as they  abstract the differences between the native variables types between different architectures.  Try #include <stdint.h> and using the types defined here.  With standard integer types a uint16_t is the same on both the M3 and C28 core.

      Google stdint for more info

      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.
    • Ronaldo Pace
      Posted by Ronaldo Pace
      on Apr 11 2012 09:32 AM
      Intellectual875 points

      Hi Trey,

      I guess this answers half of my question and it's a nice clever way of doing it, I really like it and I'm learning more everyday as I move along with this project.

      But as you know C28 is a math monster and that's exactly the reason we're using the Concerto, there will be a nice amount of float64 being used across C28 and a few of those will have to be read from and written to C28 via ethernet across the M3 core.

      I found this table on www.arm.com about the M3 core, comparing to a PIC [  http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0234a/index.html section 4.1.5 (Data types and alignment)  ]

      Type

      Cortex-M3

      PIC

      Notes

      char

      8-bit signed

      8-bit signed

      Char is signed by default in both architectures

      short

      16-bit

      16-bit

       

      int

      32-bit

      16-bit

       

      short long

      N/A

      24-bit

       

      long

      32-bit

      32-bit

       

      long long

      64-bit

      N/A

      No 64-bit type for PIC

      float

      32-bit

      32-bit

       

      double

      64-bit

      32-bit

       

      long double

      64-bit

      N/A

       

      further researching shows me on F28M35x_Device.h

      [CODE]#ifndef DSP28_DATA_TYPES
      #define DSP28_DATA_TYPES
      typedef int int16;
      typedef long int32;
      typedef long long int64;
      typedef unsigned long long Uint64;
      typedef float float32;
      typedef long double float64;
      #endif[/CODE]

      So to finalise my question (and leave it nicely documented on the forum for the future generations):

      Can I use a long double on both cores?
      Do you suggest some other implementation of 64bits float that give the code better portability? (e.g. float64 on the C28 and _something_ on M3).

      thanks.

      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 11 2012 09:40 AM
      Verified Answer
      Verified by Ronaldo Pace
      Genius14470 points

      Ronaldo,

      Ok so I did a little looking around and I was actually able to find you some tables.  The compiler guides (search for spnu151 and spru514 on the ti homepage) are a good resource for information like this.

      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.
    • Ronaldo Pace
      Posted by Ronaldo Pace
      on Apr 11 2012 09:58 AM
      Intellectual875 points

      hi Trey,

      That is absolutely perfect.

      I'll be using the stdint.h for the integer types (staying away from the 8 bits) and float and long double for the floating point types. That way I'll be able to define a struct M3_send_data, copy its definition from the M3 project, paste it into the C28 project and rename to C28_recv_data and job done, guarantee sync between the two!

      thanks!

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Ronaldo Pace
      Posted by Ronaldo Pace
      on Apr 24 2012 10:50 AM
      Verified Answer
      Verified by Ronaldo Pace
      Intellectual875 points

      hi,

      further developing this project I stumbled across a related issue that I already fixed and I would like to share
      Also if anyone can double check if what I understood of is correct.

      On both cores I have the following structs for the shared ram portion where M3 writes and C28 reads:

      struct eeprom {
      	long double, long double, long double, long double, long double, 
      	uint64_t bit1 :1, uint64_t bit2 :1, uint64_t spare :62;
      };
      
      struct shared{
      	struct eeprom config;
      	long double;
      	uint64_t bit1 :1, uint64_t spare :63;
      };
      
      struct m3_shared_data {
      	struct shared items[MAX_ITEMS];
      };

      that's how I made it work. And in this configuration sizeof(struct eeprom) is 48 bytes

      but if I change the uint64_t to uint16_t and (of course) reduce the spare bits to 14 and 15 bits respectively, on C28 my memory sized will be reduced as expected, but on M3 struct eeprom will still use the 48 bytes instead of the expected 42 bytes. I also tested with uint32_t and the results still the same.

      As far as I understood this is happening because of note 2 on the corner of  Table 5-1 of the M3 page.
      "In TIARM9 ABI mode, 64bits data is aligned on a 32-bit boundary. In EABI mode, 64-bit data is aligned on a 64-bit boundary"

      Which means, the Concerto is EABI mode and the long double on the struct shared must align to 64-bit boundary of data. And the same issue would be visible if struct shared was using uint32 (or16) as the next long double on the array of struct shared would have to align to the next 64-bit.

      Is that it ???

      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 24 2012 12:57 PM
      Genius14470 points

      Ronaldo, you are absolutely correct.

      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