AnsweredAssumed Answered

Bad C Code in conjunction with STM32-MAT/TARGET V4.4.1

Question asked by michaeL on Feb 13, 2017
Latest reply on Feb 17, 2017 by michaeL

Dear STM32 supporters,

 

I recently updated to V4.4.1 of the MATLAB/Simulink library "STM32-MAT/Target". (See also the resolved question at

https://community.st.com/thread/36047-matlabsimulink-stm32mattarget-blocks-generate-warnings-regarding-nargchk-function). I am using MATLAB R2016b.

The code generation works fine. But the generated C codes has misktakes:

 

H-File:

/* ADC1 Regular channel Converted value DMA buffer */
extern uint16_t ADC1_RegularConvertedValue[0];

 

An Array with the size of 0 is invalid. I had expected here the value 2 as my model also shows "Nb of regular channels: 2".

 

The code tries to access invalid array elements (each element is invalid):

 

C-File:

  /* ADC1 Regular channel DMA buffer pointer initialization*/
  ADC1_DmaBuff = &ADC1_RegularConvertedValue[0];
  /* ADC1 Regular channel DMA Half transfer complete buffer pointer initialization*/
  ADC1_DmaHalf = &ADC1_RegularConvertedValue[0];
  /* ADC1 Regular channel DMA Full transfer complete buffer pointer initialization*/
  ADC1_DmaFull = &ADC1_RegularConvertedValue[0/2 - 1];

 

0/2-1=-1 is also strange!

 

Can you confirm this?

Is this an issue of MAT/Target V4.4.1?

Outcomes