ST32F100 Discovery & KEIL problem

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

ST32F100 Discovery & KEIL problem

Post by alexblack »

Hello.
I tried to compile demo project from ChibiOS 2.6.7 in Keil compiler and have some troubles.
With default settings in mcuconf.h file all is ok. But if I change settings to use intranal RC osc the compiller generate an error:

Code: Select all

..\..\..\os\hal\platforms\STM32F1xx\hal_lld_f100.h(789): error:  #35: #error directive: "STM32_PLLCLKOUT outside acceptable range (STM32_PLLOUT_MIN...STM32_PLLOUT_MAX)"
  #error "STM32_PLLCLKOUT outside acceptable range (STM32_PLLOUT_MIN...STM32_PLLOUT_MAX)"

The settings are:

Code: Select all

/*
 * HAL driver system settings.
 */
#define STM32_NO_INIT                       FALSE
#define STM32_HSI_ENABLED                   TRUE
#define STM32_LSI_ENABLED                   FALSE
#define STM32_HSE_ENABLED                   TRUE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_SW                            STM32_SW_PLL
#define STM32_PLLSRC                        STM32_PLLSRC_HSI
#define STM32_PLLXTPRE                      STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE                  3
#define STM32_HPRE                          STM32_HPRE_DIV1
#define STM32_PPRE1                         STM32_PPRE1_DIV1
#define STM32_PPRE2                         STM32_PPRE2_DIV1
#define STM32_ADCPRE                        STM32_ADCPRE_DIV2
#define STM32_MCOSEL                        STM32_MCOSEL_NOCLOCK
#define STM32_RTCSEL                        STM32_RTCSEL_NOCLOCK
#define STM32_PVD_ENABLE                    FALSE
#define STM32_PLS                           STM32_PLS_LEV0

If I disable the #error directive the compilation is ok and the board works fine but freq is 12Mhz (I printed STM32_SYSCLK).
If I change ST32_PLLMUL_VALUE to 4 - the compilation is with no errors but real frequency is set to 16MHz.

When I use IAR compiller all work fine! It seems that is KEIL preprocessor issue or what ?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ST32F100 Discovery & KEIL problem

Post by Giovanni »

Are you using the correct board files in the project?

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: ST32F100 Discovery & KEIL problem

Post by alexblack »

I took clear demo project from "ChibiOS_2.6.7\demos\ARMCM3-STM32F100-DOSCOVERY\".
Comipled it with default settings. The compiller generated warnings:

Code: Select all

..\..\..\boards\ST_STM32VL_DISCOVERY\board.h(40): warning:  #47-D: incompatible redefinition of macro "STM32F10X_MD_VL"
  #define STM32F10X_MD_VL

Because Keil define 'STM32F10X_MD_VL' in global scope by default.
I changed board.h file to:

Code: Select all

 \boards\ST_STM32VL_DISCOVERY\board.h
...
36 /*
37  * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h.
38  */
39 #ifndef STM32F10X_MD_VL
40 #define STM32F10X_MD_VL
41 #endif
...

Another problem was from linker:

Code: Select all

linking...
.\obj\ch.axf: Error: L6218E: Undefined symbol Image$$RW_IRAM1$ZI$$Limit (referred from chmemcore.o).
.\obj\ch.axf: Error: L6218E: Undefined symbol Image$$RW_IRAM2$$Base (referred from chmemcore.o).
Finished: 0 information, 0 warning and 2 error messages.

I changed file chconf.h to

Code: Select all

...
73 #if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
74 #define CH_MEMCORE_SIZE                 1024
75 #endif
...

Al is ok.
Change few settings in mcuconf.h:

Code: Select all

...
36 #define STM32_NO_INIT                       FALSE
37 #define STM32_HSI_ENABLED                   TRUE
38 #define STM32_LSI_ENABLED                   FALSE
39 #define STM32_HSE_ENABLED                   TRUE
40 #define STM32_LSE_ENABLED                   FALSE
41 #define STM32_SW                            STM32_SW_PLL
42 #define STM32_PLLSRC                        STM32_PLLSRC_HSI
...

And have this error:

Code: Select all

..\..\..\os\hal\platforms\STM32F1xx\hal_lld_f100.h(789): error:  #35: #error directive: "STM32_PLLCLKOUT outside acceptable range (STM32_PLLOUT_MIN...STM32_PLLOUT_MAX)"
  #error "STM32_PLLCLKOUT outside acceptable range (STM32_PLLOUT_MIN...STM32_PLLOUT_MAX)"
..\..\..\boards\ST_STM32VL_DISCOVERY\board.c: 0 warnings, 1 error

I opened this project from IAR without any changes and it is compiled.
Everyone can repeat this.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ST32F100 Discovery & KEIL problem

Post by Giovanni »

The problem with Image$$RW_IRAM1$ZI$$Limit etc is known, Keil changed something in latest versions and you have to write the symbols in the options by replacing $$ with $$$$ (four of them instead of two). This is fixed already in the upcoming 2.6.8.

About the other problem, you must have differences in projects, the code should compile exactly the same under GCC, IAR and Keil.

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: ST32F100 Discovery & KEIL problem

Post by alexblack »

Hi.
But that is the problem that Keil do not want to compile clear demo project (and my too). You may try to do this and see.
Before I used IAR all time but now want to try Keil and see problems. I thoroughly look at the code but do not see anything what can help to understand what happen. Are realy KEIL has preprocessor bugs? I dowloaded latest version from off site and the errors in place.
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: ST32F100 Discovery & KEIL problem

Post by alexblack »

Hello. I solved my problem.
I am sorry. I was not paid attention and did not noticed that when using the internal oscillator the source frequency for PLL is divided by two. That this when switch between external clock to internal also need to change PLL_CLOCK_MUL.
Post Reply