• 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 » 28035 CLA assembly macro issue
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

    28035 CLA assembly macro issue

    This question is answered
    Dan K87420
    Posted by Dan K87420
    on May 01 2012 17:45 PM
    Prodigy110 points

    Hi,

    I'm working on a 28035, using CCSV4 and am trying to develop a CLA program.  I got a simple framework working that had a simple CLA program, Charger.0-CLA.asm, that just read a var from shared memory and output the var to PWM.  I was happy.  Then, I created a macro file and called it Charger.0-CLA_Macros.asm.  I added a line: .include "Charger.0-CLA_Macros.asm" in the original CLA program then referenced routines from the macro file in it.  I got no errors.  But after awhile I got suspicious of the macro file - I would periodically build the project and everything would always build without errors.  I then purposely inserted an assembler line into the macro file ("blurg") that I knew should cause some kind of error.  It did not.  I tried looking at the assembler listings generated - it did not look like it was reading, acknowledging or expanding the macros in any way shape or form.  If I put "blurg" in the 'normal' CLA program, Charger.0-CLA.asm, the assembler would throw an error.  I then tried checking the assembler options build property box (preprocess assembly source, expand macros) and this caused the assembler to choke on the .cdecls   C,LIST,"Charger.0-CLAShared.h" line in my 'normal' CLA program claiming that it could not open the Charger.0-CLAShared.h file.  The program worked fine in it's simple form with that .cdecl statement (without the expand macro enabled).  What's going on?  What do I need to do to force the assembler to incorporate my macro file and be able to process it correctly?

    Thanks,

    Dan

    PS:  Some source:

    Executing from _CLOSED_LOOP seems to work fine (if I don't build with the expand macros feature).  The macros I've put in seem to be ignored.

    ;// Include variables and constants that will be shared in the
    ;// C28x C-code and CLA assembly code. This is accomplished by
    ;// using .cdecls to include a C-code header file that contains
    ;// these variables and constants

    .cdecls C,LIST,"Charger.0-CLAShared.h"


    ;// The following files have the assembly macros used in this file.
    ; MACRO includes
    .include "Charger.0-CLA_Macros.asm"

    ;// To include an MDEBUGSTOP (CLA breakpoint) as the first instruction
    ;// of each task, set CLA_DEBUG to 1. Use any other value to leave out
    ;// the MDEBUGSTOP instruction.

    CLA_DEBUG .set 1

    ; label to DPCLA initialization function
    .def _DPL_CLAInit

    ; dummy variable for pointer initialisation
    ZeroNetCLA .usect "ZeroNetCLA_Section",2,1,1 ; output terminal 1

    .text
    _DPL_CLAInit:
    ZAPA
    MOVL XAR0, #ZeroNetCLA
    MOVL *XAR0, ACC

    ; do CLA and CLA macro initialization here
    ;---------------------------------------------------------
    .if(INCR_BUILD = 1)

    .endif
    ;---------------------------------------------------------
    LRETR


    ;// CLA code must be within its own assembly section and must be
    ;// even aligned.
    ;// Note: since all CLA instructions are 32-bit
    ;// this alignment naturally occurs and the .align 2 is most likely
    ;// redundant

    .sect "Cla1Prog"
    .align 2

    _Cla1Prog_Start:

    _Cla1Task1:
    MNOP
    MNOP
    ;instruction to halt the CLA when debugging
    .if(CLA_DEBUG = 1)
    MDEBUGSTOP
    .endif

    ;task specific code
    .if(INCR_BUILD = 1)
    GET_Iin
    TEST_Iin
    GET_Vin
    TEST_Vin
    GET_Vout
    TEST_Vout

    MMOVZ16 MR0, @_FaultStatus ; get fault status
    MNOP ;
    MNOP ;
    MNOP ;
    MBCNDD _DISABLE_PWMS, NEQ ; if ZF != 0, disable and exit
    MNOP ;
    MNOP ;
    MNOP ;

    MMOVZ16 MR0, @_CLA_Mode ; check disabled mode
    MNOP ;
    MNOP ;
    MNOP ;
    MBCNDD _DISABLE_PWMS, EQ ; if ZF = 0, disable and exit
    MNOP ;
    MNOP ;
    MNOP ;

    ENABLE_BUCK_PWM
    ENABLE_BOOST_PWM

    MMOVZ16 MR0, @_CLA_Mode ; get current CLA Mode
    MMOVXI MR1, #0x01 ; check closed loop
    MAND32 MR0, MR0, MR1 ; check closed loop
    MNOP ;
    MNOP ;
    MNOP ;
    MBCNDD _CLOSED_LOOP, NEQ ; if ZF != 0, branch
    MNOP ;
    MNOP ;
    MNOP

    _OPEN_LOOP: ;
    MMOVZ16 MR0, @_BuckPWMIn ; get open loop command
    MMOV16 @_EPwm3Regs.CMPA.half.CMPA,MR0 ; output to buck pwm
    MMOVZ16 MR0, @_BoostPWMIn ; get open loop command
    MMOV16 @_EPwm2Regs.CMPA.half.CMPA,MR0 ; output to boost pwm
    MSTOP
    MNOP
    MNOP
    MNOP


    _CLOSED_LOOP:

    MMOVXI MR0,#0x100
    MMOV16 @_EPwm3Regs.CMPA.half.CMPA,MR0 ; output to boost pwm
    MMOV16 @_EPwm2Regs.CMPA.half.CMPA,MR0 ; output to boost pwm
    .endif

    MSTOP
    MNOP
    MNOP
    MNOP

    _DISABLE_PWMS:
    DISABLE_BUCK_PWM
    DISABLE_BOOST_PWM

    MSTOP
    MNOP
    MNOP
    MNOP
    _Cla1T1End:

    CLA Macro 28035 assembler CCSV4
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Vishal_Coelho
      Posted by Vishal_Coelho
      on May 02 2012 11:15 AM
      Expert5745 points

      Hi Dan

      if you copy the macro to the main file , the one with the tasks, does it work?. In "Charger.0-CLA_Macros.asm" declare a usect variable and look for its symbol in the .map file just to make sure the file is being pulled in.

      Regards,

      Vishal

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Dan K87420
      Posted by Dan K87420
      on May 03 2012 13:14 PM
      Verified Answer
      Verified by Lori Heustess
      Prodigy110 points

      Hi Vishal,

      I'm not sure how, but things seem to have resolved themselves.  I am now able to see cause and effect in the macro file.  The one thing that I don't understand is why when I enable  the assembler options build property box (preprocess assembly source, expand macros),  this causes the assembler to choke on the .cdecls   C,LIST,"Charger.0-CLAShared.h" line in my 'normal' CLA program claiming that it could not open the Charger.0-CLAShared.h file.  I have left it unchecked for now since everything is working the way I expect, but am not sure what the expand macro selection is supposed to do for you.

      Thanks,

      Dan

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Vishal_Coelho
      Posted by Vishal_Coelho
      on May 03 2012 15:42 PM
      Expert5745 points

      Dan,

      Im not sure i know the root cause of this. But if you are willing to post a sample project, I'd be happy to look into it.

      Regards,

      Vishal

      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