Hello all, I am getting a compiler error saying " error:expected a declaration". It sounds like I have not declared a variable as a type. I have declared a variable as 'int usePI = 0;' and then later in the code I have if(usePI){ several lines of code }. The if(usePI) line is where the compiler complains about a declaration, but I have declared it. I am pasting the code up to where the error happens below. I am using CCS 3.3.59.4 and the TI IDE v 5.98.0.339, BIOS 5.32 I appreciate any help. Thanks
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
#include "SineTable.h" // Contains look-up table used in Clarke-Park transforms
#include "ClarkePark.h" // Include header for the CLARKEPARK object
#include "PosSpeed.h" // Header for QEP and Speed
#include "PIController.h" // Header for PI controller
#include "CLF.h" // Header for Control Lyapunov Function Controller
#include "InvParkClarke.h" // Header for Inverse Park Transform
#include "SpaceVectorMod.h" // Header for Space Vector Modulation
#include "PWM.h" // Header for PWM update
const float SYSTEM_FREQUENCY = 150; // System clock (MHz)
const float ISR_FREQUENCY = 5; // Sample frequency (kHz)
// Configure which ePWM timer interrupts are enabled at the PIE level:
#define PWM1_INT_ENABLE 1
// Configure the period for each timer
#define PWM1_TIMER_TBPRD 0x1FFF
// Configure ADC
#define ADC_usDELAY 5000L
#define ADC_CKPS 0x1 // ADC module clock = HSPCLK/2*ADC_CKPS = 25.0MHz/(1*2) = 12.5MHz
#define ADC_SHCLK 0xf // S/H width in ADC module periods = 16 ADC clocks
#define Volt_Scale 45.77637e-6 // Scale factor for volts
#define Volt_Offset -1.5
#define Current_Scale 0.0443
// Prototype statements for functions found within this file.
interrupt void FOC_isr(void);
void InitEPwmTimer(void);
// Global variables used in this example
float CurrentPhase1;
float CurrentPhase2;
float rotorangle;
float speedRef = 1;
float IdRef = 0;
long loopcnt = 0;
int usePI = 0; //set to one for PI control
// Instance objects
CLARKEPARK clarkpark = CLARKEPARK_DEFAULTS;
POSSPEED qep_posspeed = POSSPEED_DEFAULTS;
if(usePI){
PICONTROLLER pi_speed = PICONTROLLER_DEFAULTS;
PICONTROLLER pi_Id = PICONTROLLER_DEFAULTS;
PICONTROLLER pi_Iq = PICONTROLLER_DEFAULTS;
}
else{
CLF clf = CLF_DEFAULTS;
}
//More code here ...