Skip to main content
Sidlauskas.David
Associate III
March 17, 2018
Question

Bug Report: CubeMX Generates Bad Init Code

  • March 17, 2018
  • 2 replies
  • 1723 views
Posted on March 17, 2018 at 21:08

Using CubeMX V4.7.25.0 I get initialization code for RTC.c that won't compile 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

Generate code for TrueStudio

When I build the generated code I get the following errors:

..\..\..\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.

Is this a CubeMx bug?

Dave

#cubemx-bug-init.-code
This topic has been closed for replies.

2 replies

imi415
Associate
March 18, 2018
Posted on March 18, 2018 at 15:48

As a temporary workaround, I replaced these lines with which generated by older version of CubeMX.

However, this will be replaced back by CubeMX after re-generation.

LL_PWR_EnableBkUpAccess

();

/* Enable BKP CLK enable for backup registers */

LL_APB1_GRP1_EnableClock

(LL_APB1_GRP1_PERIPH_BKP);

Replaced with:

HAL_PWR_EnableBkUpAccess

();

/* Enable BKP CLK enable for backup registers */

__HAL_RCC_BKP_CLK_ENABLE

();

Sergey Starovoitov
Associate
June 5, 2018
Posted on June 05, 2018 at 16:00

 ,

 ,

I put this code into the user code section before the problem code to avoid the CubeMX code replacement:

♯ warning These definitions is a temporary workaround. Remove them, when the STM32CubeMX bug will be fixed.

 ,

♯ define LL_PWR_EnableBkUpAccess() HAL_PWR_EnableBkUpAccess()

 ,

♯ define LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_BKP) __HAL_RCC_BKP_CLK_ENABLE()
Technical Moderator
March 22, 2018
Posted on March 22, 2018 at 15:25

Hello,

This is knownissue already reported to CubeMx team for fix.

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

Sorry for the inconvenience it may bring.

Kind Regards,

Imen

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