This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hi,
I'm using TMS320F28035 (Piccolo) with CCS Vers. 6.1.0.00104 (and C code both for CPU and CLA) in order to control a boost converter in discontinuous conduction mode with Peak current mode controlPWM(choke current at the beginning of a switch interval should be zero and I'm testing this condition in CLA). CLA task1 executes the C code for controlling PWM1A in order to get constant output voltage from the converter.
If at the beginning of switch interval the current is greater than a threshold value I try to swith PWM1A off for the current switch interval (in the next interval it should turn on again automatically). Doing this via putting 0 into the DAC and with the help of the analog comparator works fine (but might be slower than necessary). I'd like better avoide the analog path and generate a SW trip to turn off PWM1A. Unfortunately this doesn't work and it seems to me that PWM1 simply stops (forever, which isn't what I intended, not at all). Could there be an adressing problem in the CLA (32 bit pointer in CPU, 16 bit pointer in CLA???) when I read and
write EPwm registers the same way in CPU and CLA?
Many thanks in advance for any helpful suggestions.
Regards,
Leo Rohrecker
// ===== initialization in CPU code: =====
EALLOW;
// Setup compare: A = PWM max DC, B = ADC SOC
EPwm1Regs.CMPA.half.CMPA = 0; // DC = 0
EPwm1Regs.CMPB = ADC_SOC_OFFSET;
// Clock ratios to SYSCLKOUT
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
// period
EPwm1Regs.TBPRD = PWM_TIMER_TBPRD;
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
// Set actions
EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET; // Set PWM1A on Zero
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // max duty cycle
EPwm1Regs.AQCTLB.bit.ZRO = AQ_SET; // Set PWM1B on Zero
EPwm1Regs.AQCTLB.bit.CBU = AQ_CLEAR; // ADC SOC 1st group
// CBC trip, define an event (DCAEVT2)
// (see SPRUGE9E, Ex. 14)
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP1OUT; // DCAH = comparator 1 output
EPwm1Regs.TZDCSEL.bit.DCAEVT2 = TZ_DCAH_HI; // DCAEVT2 = DCAH high (will become active as comp. output goes hi)
EPwm1Regs.DCACTL.bit.EVT2SRCSEL = DC_EVT2; // DCAEVT2 = DCAEVT2 (not filtered)
EPwm1Regs.DCACTL.bit.EVT2FRCSYNCSEL = DC_EVT_ASYNC; // take async path
EPwm1Regs.TZSEL.bit.DCAEVT2 = 1; // enable CBC event
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // EPWM1A will go low
EPwm1Regs.TZCTL.bit.TZB = TZ_NO_CHANGE; // EPWM1B unaltered
// define SOCs (ADC trigger)
EPwm1Regs.ETSEL.bit.SOCBEN = 1; // enable SOC B
EPwm1Regs.ETSEL.bit.SOCBSEL = ET_CTRU_CMPB; // SOC from CPMB on upcount
EPwm1Regs.ETPS.bit.SOCBPRD = 1; // Generate pulse on 1st event
EDIS;
// ===== run time actions in CLA code: =====
// check for CCM by current measurement at beginning of switch interval
if ((float32)ADC_U_I1 > U_I_START_THRESH_CCM_TIL) {
// start current too high .. turn off immediately
EALLOW;
//EPwm1Regs.TZFRC.bit.DCAEVT2 = 1; // force DCAEVT2 trip condition ... doesn't work, either !!!!!
EPwm1Regs.TZFRC.bit.CBC = 1; // force CBC trip ... doesn't work !!!!!
EDIS;
//Comp1Regs.DACVAL.bit.DACVAL = 0; // turn off immediately via analog comp. (alternative, works fine, but slower than digital path)
}
// controller code etc....
// ...
// --------------------------------------- end ---------------------------------------
Hi Vishal,
I think the necessary defines should be included to my code. The CLA C code file starts with
#include "DSP28x_Project.h"
and DSP28x_Project.h Contents is:
//###########################################################################
//
// FILE: DSP28x_Project.h
//
// TITLE: DSP28x Project Headerfile and Examples Include File
//
//###########################################################################
// $TI Release: F2803x C/C++ Header Files and Peripheral Examples V126 $
// $Release Date: November 30, 2011 $
//###########################################################################
#ifndef DSP28x_PROJECT_H
#define DSP28x_PROJECT_H
#include "DSP2803x_Cla_typedefs.h"// DSP2803x CLA Type definitions
#include "DSP2803x_Device.h" // DSP2803x Headerfile Include File
#include "DSP2803x_Examples.h" // DSP2803x Examples Include File
#endif // end of DSP28x_PROJECT_H definition
and DSP2803x_CLAtypedefs.h Contents is:
//###########################################################################
//
// FILE: DSP2803x_Cla_typedefs.h
//
// TITLE: Variable type definitions
//
//###########################################################################
// $TI Release: F2803x C/C++ Header Files and Peripheral Examples V126 $
// $Release Date: November 30, 2011 $
//###########################################################################
#ifndef CLASHARED_C_H_
#define CLASHARED_C_H_
//---------------------------------------------------------------------------
// For Portability, User Is Recommended To Use Following Data Type Size
// Definitions For 16-bit and 32-Bit Signed/Unsigned Integers:
//
#ifndef DSP28_DATA_TYPES
#define DSP28_DATA_TYPES
typedef short int16;
typedef long int32;
typedef unsigned char Uint8;
typedef unsigned short Uint16;
typedef unsigned long Uint32;
typedef float float32;
typedef long double float64;
#endif
#ifndef _TI_STD_TYPES
#define _TI_STD_TYPES
/*
* These types are also defined in DSP/BIOS 5.x's <std.h> and the
* SYS/BIOS 6.x's <xdc/std.h> files. We need to protect their
* definition with the #ifndef/#define guard to avoid the duplicate
* definition warning.
*
* SYS/BIOS requires that the <xdc/std.h> file be included before
* any other .h files.
*/
#endif
// Suppress warnings casting CLA pointers
#pragma diag_suppress 70,770,232
// Macros to manipulate pre-processor to generate a header file name
// at compile time that is based on the test name and can be used as
// an argument to #include
#define XSTRINGIZE(s) STRINGIZE(s)
#define STRINGIZE(s) #s
#define XCONCAT(x,y) CONCAT(x,y)
#define CONCAT(x,y) x##y
#ifdef __TMS320C28XX_CLA0__
struct MSTF_SHADOW_BITS { // bits description
Uint16 LVF:1; // 0 Latched Overflow Flag
Uint16 LUF:1; // 1 Latched Underflow Flag
Uint16 NF:1; // 2 Negative Float Flag
Uint16 ZF:1; // 3 Zero Float Flag
Uint16 rsvd1:2; // 5:4 Reserved
Uint16 TF:1; // 6 Test Flag
Uint16 rsvd2:2; // 8:7 Reserved
Uint16 RNDF32:1; // 9 Rounding Mode
Uint16 rsvd3:1; // 10 Reserved
Uint16 MEALLOW:1; // 11 MEALLOW Status
Uint16 RPCL:4; // 15:12 Return PC: Low Portion
Uint16 RPCH:8; // 23:16 Return PC: High Portion
Uint16 rsvd4:8; // 31:24 Reserved
};
extern __cregister volatile unsigned int MSTF;
#endif //__TMS320C28XX_CLA0__
#if defined(__TMS320C28XX_CLA0__)
typedef struct { Uint32 low32; Uint32 high32; } Uint64;
#else
typedef unsigned long long Uint64;
#endif
#ifndef __TMS320C28XX__
#define __cregister
#endif //__TMS320C28xx__
#define Uint16 unsigned short
#endif /*CLASHARED_C_H_*/
--------------------------------------------
I started code development for Piccolo in 2011/12, therefore these TI files are from 2011. But my code worked fine, until I tried to use SW trip within CLA C code.
Best regards,
Leo
Hi Vishal,
Access to the PWM Registers from CLA is working when I use the commands __meallow() / __medis() with protected registers. It would be nice if the C Compiler generated a warning or an error message after finding commands like EALLOW or EDIS in a .cla file.
Thank you for your help!
Regards,
Leo