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.

TMS320F28335: Code generation TMS320F28335 AdcInit function

Part Number: TMS320F28335


Hi,

I work on code generation using Matlab 2018b + Code Composer V6, I generate C code using Embedded coder with ert.tlc target file, my target is a C2000 TMS320F28335.

My Simulink model uses different interfaces (I2C, SPI, ...) and especially an ADC_INA block named "ADC" which is configured correctly. When I try to generate my model using all blocks except ADC, the code is generated without error.

When I generate code including the ADC interface, I get an error when generating the source file ADC.c : "ADC.c line 29: error: identifier "adcInitFlag" is undefined".

Indeed, when I look into ADC.c, at the beginning of the Start function I can see a condition :

if (adcInitFlag == 0) {

InitAdc();

}

And since I see no declaration of adcInitFlag in the function, of course it returns an error.

My question is : since I can set this "init flag" nowhere in my model, how can I avoid this error ?

In the past I generated code on the same model using Matlab 2013a instead, and this condition on adcInitFlag didn't exist, so I never got the error. Could it have been added since 2013 ?

Thank you for your help,

Best regards,

François

  • Francois,

    We need guidance from MathWork team on this issue. Please expect response by tomorrow.

  • Hi Francois,

    Please try building the example model 'c280x_2833x_adcpwmasynctest_ert.slx' do you notice same issue?

    I suspect the ADC block in your model is not for F28335 controller.

  • Hi,

    Many thanks for the suggestion that allowed me to find out the issue. Actually my ADC block was OK, but the problem was the declaration of the subsystem where my block was. The subsystem (named "ADC") was atomic but built as "non reusable", and assuming my main model was named "main.slx", at the build the adcInitFlag was declared as static in "main_ert.c", and my ADC atomic subsystem (requiring adcInitFlag) was built in "ADC.c" so it couldn't see the declaration of adcInitFlag. 

    I changed all the code generation parameters of my subsystems to "Auto" instead of "Reusable" (since it was converted in "non reusable" systematically), and it works fine. 

    Thanks again, and regards !

    François