TMS320F2800155: SFRA gui greyed out.

Part Number: TMS320F2800155
Other Parts Discussed in Thread: SFRA, C2000WARE

Tool/software:

Hey.

Im trying to use SFRA in a project.
I can connect using the gui, but even when it connectes, all controls are greyed out.
Im using windows 11 -  Language was set to english (united states).

I'll attach the .h/.c files that I use to handle the calls.
In my main() function I call 

SFRA_PORT_background();

in every loop.
I am running a pwm at 100kHz frequency, and using the ADC to measure in the middle of the duty cycle, using the DCL_runPI_C7() function pi controller.
Im polling the ADC flag to run the controller when it's done its sample/conversion.
Heres the relevant part of the code that gets run when ADC is done:

    // Clear ADC end-of-sequence flag once.
    AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;


    //float ref_ctrl = SFRA_PORT_inject(setpoint);   // returns reference + injected perturbation
const float ADC_INV = (1.0f/4096.0f);

float ref_ctrl_pu = SFRA_PORT_inject(setpoint * ADC_INV);  // per-unit into SFRA
float ref_ctrl    = ref_ctrl_pu * 4096.0f;                  // back to counts for the PI

    // PHASE 1 -----------------------------------------------------------    
    // 1. Calculate mean of adc sample.
    float compare = pwm_compare[ePWM1];
    float old_duty_cycle = 1.0f - (inv_period * compare);
    float adc_avg = (float)AdcaResultRegs.ADCRESULT1 * old_duty_cycle;

    // 2. Do PI calculations and scale.
    float pi_output = DCL_runPI_C7(&pi_current1, ref_ctrl, adc_avg); // Run the PI controller.

    // 3. Clamp new compare value, and update the array copy
    compare = period - (pi_output * period);
    pwm_compare[ePWM1] = compare;
    EPwm1Regs.CMPA.bit.CMPA = __f32toui16r(compare);

float u_sfra = pi_output;            // already 0..1
float y_sfra = adc_avg * ADC_INV;    // feedback in per-unit
SFRA_PORT_collect(&u_sfra, &y_sfra);


Any help it getting this utility to work?




SFRA_PORT.h

#include "sfra_port.h"
#include <math.h>

// ---------- Config knobs ----------
#define SFRA_START_HZ         10.0f
#define SFRA_STOP_HZ          8000.0f
#define SFRA_PTS_PER_DECADE   20          // 10/20/40 are typical
#define SFRA_INJ_AMPL         0.01f       // 1% of normalized ref
#define SFRA_SETTLE_SPEED     1           // 0=slowest .. 3=fastest (SDK enum/int)
#define SFRA_MAX_POINTS       128         // must be >= actual points

// ---------- State ----------
static SFRA_F32 sfra;
// response/freq vectors (host reads these)
static float h_mag[SFRA_MAX_POINTS];
static float h_phase[SFRA_MAX_POINTS];
static float gh_mag[SFRA_MAX_POINTS];
static float gh_phase[SFRA_MAX_POINTS];
static float cl_mag[SFRA_MAX_POINTS];
static float cl_phase[SFRA_MAX_POINTS];
static float freq[SFRA_MAX_POINTS];

// SCI instance for GUI
#define SFRA_GUI_SCI_BASE   SCIA_BASE
#define SFRA_GUI_BAUD       115200U


// compute how many points we’ll actually use
static inline int16_t calc_num_points(void)
{
    const float decades = log10f(SFRA_STOP_HZ) - log10f(SFRA_START_HZ);
    int16_t n = (int16_t)(ceilf(decades * (float)SFRA_PTS_PER_DECADE)) + 1;
    if (n > SFRA_MAX_POINTS) n = SFRA_MAX_POINTS;
    return n;
}

void SFRA_PORT_init(float ctrlISR_Hz)
{
#if ENABLE_SFRA
    SFRA_F32_reset(&sfra);

    const int16_t npts   = calc_num_points();
    const float fstep = 1.0f / (float)SFRA_PTS_PER_DECADE;

    // Configure the object
    SFRA_F32_config(&sfra,
                    /* isrFrequency     */ ctrlISR_Hz,
                    /* injectionAmplitude*/ SFRA_INJ_AMPL,
                    /* noFreqPoints     */ npts,
                    /* fraSweepStartFreq*/ SFRA_START_HZ,
                    /* freqStep         */ fstep,
                    /* h_magVect        */ h_mag,
                    /* h_phaseVect      */ h_phase,
                    /* gh_magVect       */ gh_mag,
                    /* gh_phaseVect     */ gh_phase,
                    /* cl_magVect       */ cl_mag,
                    /* cl_phaseVect     */ cl_phase,
                    /* freqVect         */ freq,
                    /* speed            */ SFRA_SETTLE_SPEED);

    // clear any previous results
    SFRA_F32_resetFreqRespArray(&sfra);

    // Initialize the frequency vector (log steps)
    SFRA_F32_initFreqArrayWithLogSteps(&sfra, SFRA_START_HZ, fstep);

    // ---- GUI SCI setup  ----

    // Get LSPCLK frequency
    uint32_t lsp_hz = SysCtl_getLowSpeedClock(DEVICE_SYSCLK_FREQ);
    SFRA_GUI_config(SFRA_GUI_SCI_BASE,
                    lsp_hz,
                    SFRA_GUI_BAUD,
                    17, GPIO_17_SCIA_RX,
                    24, GPIO_24_SCIA_TX,
                    0, 0, 0,
                    &sfra,
                    1);

#endif
}

void SFRA_PORT_background(void)
{
#if ENABLE_SFRA

    //SCI_writeCharNonBlocking(SFRA_GUI_SCI_BASE, '@');   // Temporary test.

    SFRA_F32_runBackgroundTask(&sfra);
    SFRA_GUI_runSerialHostComms(&sfra);

#endif
}



  • Andres,

    Could you please share the GUI snippet where the option was greyed out? That will help me better understand the issue.

    From your description, I gather that the function SFRA_PORT_background() is not being called continuously, whereas it should be invoked at regular intervals.

    Refer example from "C2000Ware_DigitalPower_SDK_v\libraries\sfra\examples" on how background tasks are used.

    Thanks & Regards,

    Shashank