cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMx Generates Garbage Init Code??

Sidlauskas.David
Associate II
Posted on March 16, 2018 at 02:05

Using CubeMX V4.7.1 I get garbage initialization code for RTC.c when I request initialization be generated as .c.h file pairs.

Simple demo case:

Start CubeMX

New Project

Select STMf103C8Tx as target

Under Pins Select RTC-> Activate Clock Source.

Under Project settings:

   Project Name: Test

   Location: C:\Temp\

   Under Code Generator Tab:

         Check Generate peripheral initialization as pair of .c/.h files

Leave everything else at defaults.

Generate the code and look at rtc.c. It's not C source code. Eg.

/* RTC init function */

void MX_RTC_Init(void)

{

#n

#t#t/**Initialize RTC Only #n#t#t*/

#thrtc.Instance = RTC;

#thrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;

#thrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM;

#tif (HAL_RTC_Init(&hrtc) != HAL_OK)

#t{

#t#t_Error_Handler(__FILE__, __LINE__);

#t}

Followed by what looks like a lot of Java error messages.

Looks like a CubeMX bug to me. If I leave the init stuff in main, it works OK.

Dave

3 REPLIES 3
Imen.D
ST Employee
Posted on March 16, 2018 at 15:39

Hello

Sidlauskas.David

,

Please download and update the new version

/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fcontent%2Fst_com%2Fen%2Fproducts%2Fdevelopment-tools%2Fsoftware-development-tools%2Fstm32-software-development-tools%2Fstm32-configurators-and-code-generators%2Fstm32cubemx.html

which fix this issue.

Best Regards,

Ime,

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Sidlauskas.David
Associate II
Posted on March 16, 2018 at 17:47

Thanks for the quick response. V 4.25.0 fixes the above issues, but there are still problems. Using the above test case and generating code for TrueStudio (Compile under root unchecked), the code will not build without errors. E.g. :

..\..\..\Src\rtc.c:73:5: warning: implicit declaration of function 'LL_PWR_EnableBkUpAccess' [-Wimplicit-function-declaration] LL_PWR_EnableBkUpAccess();

..\..\..\Src\rtc.c:75:5: warning: implicit declaration of function 'LL_APB1_GRP1_EnableClock' [-Wimplicit-function-declaration]  LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_BKP);

..\..\..\Src\rtc.c:75:30: error: 'LL_APB1_GRP1_PERIPH_BKP' undeclared (first use in this function)

     LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_BKP);

                            

If I generate code for the test project with the peripheral inits in main(), the project will then build without error.

Dave

Posted on March 22, 2018 at 15:20

Hello

Sidlauskas.David

,

I confirm this issue and it is already reported in CubeMx team for fix.

https://community.st.com/0D50X00009XkWuZSAV

Best Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen