cancel
Showing results for 
Search instead for 
Did you mean: 

Corrected clock setting from cubemx ?

Md Mubdiul Hasan
Associate III
Posted on December 16, 2016 at 03:20

Hello Everyone,

I look forward to whom who knows Cubemx well in this community,

In my generated cubemx, for GPIO initialization the code says,

static void MX_GPIO_Init(void)

{

GPIO_InitTypeDef GPIO_InitStruct;

/* GPIO Ports Clock Enable */

__HAL_RCC_GPIOC_CLK_ENABLE();

__HAL_RCC_GPIOA_CLK_ENABLE();

__HAL_RCC_GPIOB_CLK_ENABLE();

__HAL_RCC_GPIOD_CLK_ENABLE();

But the error sign of Eclipse says following

0690X00000605rsQAA.png

At this consideration the clock configuration at cubemx ,

0690X00000605pnQAA.png

During this time my RCC setting was,

0690X00000605t0QAA.png

Take a look here, if you feel any mismatch ,

void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct;

RCC_ClkInitTypeDef RCC_ClkInitStruct;

RCC_PeriphCLKInitTypeDef PeriphClkInit;

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI;

RCC_OscInitStruct.HSIState = RCC_HSI_ON;

RCC_OscInitStruct.HSICalibrationValue = 16;

RCC_OscInitStruct.LSIState = RCC_LSI_ON;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

Error_Handler();

}

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

|RCC_CLOCKTYPE_PCLK1;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)

{

Error_Handler();

}

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;

PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;

if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)

{

Error_Handler();

}

HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

/* SysTick_IRQn interrupt configuration */

HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}

1. Explain things which should be necessary here,

2. If RCC is ON then what should be the effect?

3. RCC is necessary for every design of STM32F07xxx?

Regards

Hasan

#rcc #uphill-skiing #initial-clock #gpio #cubemx

Note: this post was migrated and contained many threaded conversations, some content may be missing.
9 REPLIES 9
Posted on December 16, 2016 at 03:35

Does it compile? Eclipse has its own parser, but I'd trust the compiler over the editor.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 16, 2016 at 05:06

No Sir! 

Eclipse has its own parser

Dont you saying about it?

0690X00000605sqQAA.png

but I'd trust the compiler over the editor

What compiler and editor  got your trust? 

Posted on December 16, 2016 at 05:33

Dear Sir Clive1,

Previously the build console says,

Invoking autoreconf in build directory: C:/STM32_toolchain/Workspace/adapt_rc/Debug

Configuration failed with error

(Cannot run program ''sh'' (in directory ''C:\STM32_toolchain\Workspace\adapt_rc''): CreateProcess error=2,

Now , I realize the problem, and corrected as Executable,

0690X00000605svQAA.png

Right now, the build  says,

arm-none-eabi-gcc -mthumb -mfloat-abi=soft -E -IC:/STM32_toolchain/common/Drivers/CMSIS/Include -IC:/STM32_toolchain/common/Drivers/STM32F0xx_HAL_Driver/Inc/Legacy -IC:/STM32_toolchain/Workspace/adapt_rc/Inc -IC:/STM32_toolchain/common/Drivers/STM32F0xx_HAL_Driver/Inc -IC:/STM32_toolchain/common/Drivers/CMSIS/Device/ST/STM32F0xx/Include -O0 -g -Wall -fmessage-length=0 -ffunction-sections -c -o ''common1\\spi.o'' ''..\\common1\\spi.c''

..\common1\spi.c:36:17: fatal error: spi.h: No such file or directory

compilation terminated.

Debug folder in project tree showing object files,

0690X00000605tAQAQ.png
Posted on December 16, 2016 at 06:15

Ok, and where is SPI.H in the tree of files you are attempting to build?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 16, 2016 at 07:01

Thank you sir.

Take a look all project tree. Find what you want to see.

0690X00000605t5QAA.png

Console says,

C:/STM32_toolchain/common/Drivers/STM32F0xx_HAL_Driver/Inc/system_stm32f0xx.h:86:13: error: declaration for parameter 'SystemCoreClockUpdate' but no such parameter

extern void SystemCoreClockUpdate(void);

^

C:/STM32_toolchain/common/Drivers/STM32F0xx_HAL_Driver/Inc/system_stm32f0xx.h:85:13: error: declaration for parameter 'SystemInit' but no such parameter

extern void SystemInit(void);

^

C:/STM32_toolchain/common/Drivers/STM32F0xx_HAL_Driver/Inc/system_stm32f0xx.h:59:17: error: declaration for parameter 'SystemCoreClock' but no such parameter

extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */

^

..\Src\main.c:630:1: warning: control reaches end of non-void function [-Wreturn-type]

}

^

The error message says that the function is defined to return a value but  I am  not returning anything.?

Posted on December 16, 2016 at 16:40

I'm suggesting you use a File Manager, or whatever you use to navigate the files on your system, and find SPI.H within the file sub-directories that make up the project. Once you have found it, you need to make sure the compiler knows that path. I don't see a 'Common2' directory listed in the '-I' option in the compiler command line.

Screen shots from Eclipse aren't where you need to be looking. The compiler is telling you it can't find/open a file, you need to figure out where it is and pass that information to the compiler so it can find it too.

Not sure of the error messages in your last post, but you need to look for the first error encountered, subsequent errors may just be a result of trying to continue, so fix/address the errors in the order they occur, and rebuild as you fix each.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 19, 2016 at 06:56

I'm suggesting you use a File Manager, or whatever you use to navigate the files on your system

Are you suggesting to do in this way? 

http://stackoverflow.com/questions/10847795/how-to-browse-file-systems-in-eclipse

 

If not there is one way I saw in Help menu,

0690X00000605tUQAQ.png

find SPI.H within the file sub-directories that make up the project.

Dont you mean keep that file after making  a sub-folder under a folder  in a project folder?

If I included my spi.c history at main.c, is there any problem?

Does it have any benefit to make different file under each folder ? 

I think I am repeating same spi.c, gpio.c, tim.c in main.c. Is not a big  error?

I don't see a ''Common2'' directory listed in the ''-I'' option in the compiler command line.

Yes, I will include it in  project >> Properties >> C/C++ Build >> Settings >> Tool settings>> includes , isnt true ?

The compiler is telling you it can't find/open a file, you need to figure out where it is and pass that information to the compiler so it can find it too.

Does it means  if that file is unavailable then,

1. Look for it wheather it added or not included file.

2. Need to find from ''search'' option in whole work-space or project folder ?

 Kindly discuss to these point. 

Posted on December 19, 2016 at 18:38

Are you suggesting to do in this way?

By 'File Manager' I mean whatever you use to understand the files and directories on the machine, to move and copy them about. I use something called ZTree as I'm familiar with it, you might use the one built into Windows.

Don't you mean keep that file after making  a sub-folder under a folder  in a project folder?

If I included my spi.c history at main.c, is there any problem?

Does it have any benefit to make different file under each folder ? 

I mean you need to understand where the SPI.H file comes from in your project. I'm assuming it is in the same directory as the source, or in a ..\INC equivalent.

I'm not asking you to move or change anything, just understand where it is, and confirm it does exist. Don't have multiple copies of the same files.

Where there are a dozen files involved I'd tend to use a flat structure. If there are hundreds or thousands, then managing them in some more elegant directory structure will make more sense. Try to keep it simple.

Does it means  if that file is unavailable then,

1. Look for it whether it added or not included file.

2. Need to find from 'search' option in whole work-space or project folder ?

Include files typically don't get added to project trees, I don't use Eclipse, but the compiler is building .C files containing source, the .H files get pulled in via &sharpinclude statements, and the system must be able to find them. If it says it can't find them, then you have set something up wrong. Most likely the include paths.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
139969CGIL8