Embedded coder produces incorrect code reading from Simulink data store
3 次查看(过去 30 天)
显示 更早的评论
I have a shared structure that holds the coefficients of a biQuad filter block. This is for a 10th order filter that is implemented as 5-2nd order sections (SOS). The structure is defined as:
typedef struct {
real_T numerator[3][5];
real_T denominator[2][5];
real_T gain[6];
} userFilterSOS5;
typedef struct
{
int16_T BP_LPsel; // [0 = DC, 1 = BPF] connects to LP input
int16_T LP_HPsel; // [0 = DC, 1 = BPF, 2 = LPF] connects to HP input
int16_T HP_notchSel; // [0 = BPF, 1 = LPF, 2 = HPF] connects to notch input
int16_T output_Sel; // [0 = BPF, 1 = LPF, 2 = HPF, 3 = notch] connects to output
int32_T DCdelay;
int32_T BPdelay;
int32_T LPdelay;
int32_T HPdelay;
int32_T N1delay;
int32_T N2delay;
int32_T N3delay;
int32_T N4delay;
real_T FIRbpfCoef[301]; // FIR filt has only numerator coefs
userFilter7 LPF;
userFilter7 HPF;
userFilterSOS5 notch1;
userFilterSOS5 notch2;
userFilterSOS5 notch3;
userFilterSOS5 notch4;
} filtersBus;
It is declared as:
filtersBusSig = Simulink.Signal;
filtersBusSig.DataType = 'Bus: filtersBus';
filtersBusSig.SamplingMode = 'Sample based';
filtersBusSig.Complexity = 'real';
filtersBusSig.InitialValue = 'filtersBusStruct';
filtersBusSig.StorageClass = 'ExportedGlobal';
In the Simulink DataStoreRead block, it is specified as:
filtersBusSig.notch1.numerator(:,:)
filtersBusSig.notch1.denominator(:,:)
filtersBusSig.notch1.gain(:,:)
The embedded decoder generates the following code to read the data out of the DataStore:
/* DataStoreRead: '<S22>/notch1Coef' */
for (i = 0; i < 15; i++) {
decoder_decBPFpump_B.notch1Coef_o1[i] = filtersBusSig.notch1.numerator[i];
}
We have tried this with the Visual Studio 2013 compiler, Intel compiler, and QtCreator compiler, and all of them generate something like the following error:
../decoder-common-lib/decoder_Main_Model/testRepo/slprj/ert/decoder_decBPFpump/decoder_decBPFpump.c:
756: error: incompatible types when assigning to type ‘real_T’ from type ‘real_T *’
I understand that the embedded coder likes to convert 2D arrays to 1D vectors, but this code will not compile. Is there a way to correct this, or at least force it to generate a warning?
I should add that converting the arrays to 1D vectors is not a solution, since the block generates an error if the inputs are not in (3, N) and (2, N) format for the numerator and denominator respectively.
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!