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
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:
Any help it getting this utility to work?
#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
}