4 years, 8 months ago.

Compiler Error for L152RE not F401RE & F411RE

I made a CPU register direct access program as follows.

#include "mbed.h"
int main()
    __PWR_CLK_ENABLE(); // Enable Power Clock

I selected both ST Nucleo F401RE and F411RE board then compile it in the mbed online compiler and results is "Success!".
When I selected L152 board, the mbed online compiler made a message as follows.
Error: Identifier "PWR_CLK_ENABLE" is undefined in "main.cpp"

I downloaded "mbed-src" and check "PWR_CLK_ENABLE()" words in the source files.
I found in the following files.
"PWR_CLK_ENABLE()" is a macro definition. So I put the macro into the file.

#include "mbed.h"
#define __PWR_CLK_ENABLE()        (RCC->APB1ENR |= (RCC_APB1ENR_PWREN))
int main()
    __PWR_CLK_ENABLE(); // Enable Power Clock

Then "Success!"

For F411RE and F401RE, they have a proper path for the macro header file.
In the case of L152, why they don't have a path?
I believe that this is a simple setting issue inside of mbed online compiler environment.

Comment on this question

2 Answers

4 years, 8 months ago.

For L152 that macro was added into mbes-src in a recent revision (i just looked at mbed-src of august 12 and teh macro is not there yet), the mbed lib is based on a early version so you don't have that macro yet.

Thanks your information.
Now, they included the file and made the path.
NOW THIS PROBLEM WAS SOLVED! -> mbed online compiler out a object file with "Success"

posted by Kenji Arai 31 Oct 2014
4 years, 8 months ago.

Try including that .h file: It is possible that via an indirect path it is included for the F401/F411, but it isn't automatically included on the L152.

thank you for your quick answer!
Do you know a reason putting a priority to prepare includes files path and not serve it?
This is a exact point for my question.
Of course, I can create own header file but is this a intention for mbed policy?

posted by Kenji Arai 25 Oct 2014

How do you mean prepare paths and not serve them? Those files are not part of the standard mbed environment, they are used by the mbed environment, and as such it is better to explicitly include them if you need them.

You don't need to create your own header file, just include those you need.

That said, I looked at the files and to me it looks like both should automatically include them, so i must be missing something :P

posted by Erik Olieman 26 Oct 2014

To post an answer, please log in.