AnsweredAssumed Answered

CubeMx Generates Garbage Init Code??

Question asked by sidlauskas.david on Mar 16, 2018
Latest reply on Mar 22, 2018 by Imen D

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

Outcomes