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 initialisationZeroNetCLA .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:
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
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.
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.