7 months, 4 weeks ago.

Custom targets cannot run under mbed OS but under KEIL+HAL

Hello everyone, I want to use mbed to drive STM32F411CEYx to build my own products. I have learned the custom target (runs perfectly on STM32F407ZG) Limited by the size of the WLCSP49 package, I am not sure there is no short circuit. I wrote a simplest Blink program to test:

Mbed Studio

#include "mbed.h"
int main() {
    DigitalOut led(PH_1);
  while (1) {
    led = !led;

It didn't work, I tried a lot, and finally found that the project generated with STM32CubeMX can run successfully after compiling and downloading.


  while (1)
    /* USER CODE BEGIN 3 */
  /* USER CODE END 3 */

I'd like to know what are the possible reasons for this situation.

Praise Google Translate, and I am working hard on my English.

Any help appreciated.

1 Answer

7 months, 3 weeks ago.

Hi Zeno,

If your board is not on the supported board list: https://os.mbed.com/platforms/ you have to use something which is as close as possible to supported board and compile your project to supported board. To get it working you probably have to modify some low level files (pin mapping etc.). They can be found from mbed-os\targets\TARGET_STM\TARGET_STM32F4 (in this ST board case). It seems that there is support for TARGET_STM32F411xE.

Are you sure that PH_1 is good pin for led? It looks like oscilator output. Can you try something else as output pin for led output?

Regards, Pekka

Hi Pekka, thank you for your reply.

I created two custom targets, one is the F411CE with the problem, the other is the F407ZG, which is my development board and works fine. This means that the process of porting the target should be error free.

In addition, I tested PA1, PA9, PA15, PB0, PH1, PH0 and other pins, all of they can not work, No matter what my program writes, most of them voltage is about 1.4V, and some are close to 2.28V.

Today I tested it with mbed in keil and still can't work. The code that only uses the hal library can run normally on both boards, indicating that the error must have occurred on the way of mbed initialization, and it has nothing to do with the hal library. The error exists in the mbed-specific code.

There is only one chip on the F411CE board, and the F407ZG development board has a crystal oscillator and other originals.

I originally thought that the configuration of the oscillator did not match. I removed the crystal of the F407ZG board and found that it can still work normally, indicating that it is not a clock source error...

posted by Zeno Zhang 19 Nov 2019