cancel
Showing results for 
Search instead for 
Did you mean: 

LED don't light on Nucleo STM32F411RE

Benoît Bousquet
Associate II
Posted on October 14, 2017 at 12:59

Hi, I'm getting started with the Nucleo STM32F411RE, and the LED don't light !

Here is my main.c :

//*****************************************************************************

//

//! \file main.c

//! \brief main application

//! \version 1.0.0.0

//! \date $Creat_time$

//! \author $Creat_author$

//! \copy

//!

//! Copyright (c) 2014 CooCox.  All rights reserved.

//

//! \addtogroup project

//! @{

//! \addtogroup main

//! @{

//*****************************************************************************

&sharpinclude <stm32f4xx.h>

&sharpinclude <system_stm32f4xx.h>

&sharpinclude <stm32f4xx_rcc.h>

&sharpinclude <stm32f4xx_gpio.h>

void Init(void);

void Init(void)

{

    RCC_DeInit();

    GPIO_InitTypeDef GPIO_InitStructure_Led;

      RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

    GPIO_InitStructure_Led.GPIO_Pin = GPIO_Pin_5;

    GPIO_InitStructure_Led.GPIO_Mode = GPIO_Mode_OUT;

    GPIO_InitStructure_Led.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure_Led.GPIO_PuPd = GPIO_PuPd_NOPULL;

    GPIO_InitStructure_Led.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_Init(GPIOA, &GPIO_InitStructure_Led);

}

int main(void)

{

    Init();

    //GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_SET);

    GPIO_SetBits(GPIOA, GPIO_Pin_5);

    while(1)

    {

    }

}

//! @}

//! @}

The build is successful, and I can flash the .bin file via ST-Link Utility. But it doesn't work. The LED stays off.

There is no clue which could lead me to a solution, because all the compiling and flashing processing works fine.

Is there something missing in the code ? Something I forgot to configure ?

Thanks for your help !

#gpio #nucleo-f411 #led
7 REPLIES 7
Benoît Bousquet
Associate II
Posted on October 14, 2017 at 13:04

I forgot to precise my IDE was Coocox V2 Beta. I managed to select my toolchain path (compiler : gcc_arm_none_eabi ).

Posted on October 15, 2017 at 18:35

I don't understand the purpose of RCC_DeInit() here.

Try having it set the pin high and low in the loop, and use the debugger to step the code, confirming it is actually running your code properly, and driving the pin high/low.

The PA5 also goes to the shield connector, so watch if you have something else plugged in.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on October 15, 2017 at 23:58

I tried with and without RCC_DeInit(), which reset rcc to default settings (thought it was a config problem, so just in case..). I also tried to make de LED blink in the loop, and there is nothing plugged on the connector. It doesn't work.

I have some issue with the debbuger, I can't run it because CoIDE can't connect with my Nucleo. It says : Error: Connect failed, check config and cable connection

I downloaded St Link V2, installed it, and put the .dll file in the 'bin' folder of my IDE, but it doesn't work. But, I can flash the program via ST Link Utility. I think I am missing something in the config of my IDE, but for the moment, I can't use debugger. When I'm flashing a demo code (LEd blinking haha) it DOES work, so the board is working properly. Any idea ? The debugger would be really usefull.

Thank you for your help !

Posted on October 17, 2017 at 00:33

Here is the build :

GCC HOME: C:\Program Files (x86)\GNU Tools ARM Embedded\6 2017-q2-update\bin

compile:

[mkdir] Skipping C:\Users\Utilisateur\Desktop\essai nucleo\essai nucleo\essai nucleo\Debug\bin because it already exists.

[mkdir] Skipping C:\Users\Utilisateur\Desktop\essai nucleo\essai nucleo\essai nucleo\Debug\obj because it already exists.

[cc] Starting dependency analysis for 5 files.

[cc] Parsing ..\..\..\components\coocox-master\Semihosting\source\semihosting.c

[cc] Parsing ..\..\..\stm32f4xx.h

[cc] Parsing ..\..\..\components\coocox-master\cmsis_core\source\core_cm4.h

[cc] Parsing ..\..\..\components\coocox-master\cmsis_core\source\core_cmInstr.h

[cc] Parsing ..\..\..\components\coocox-master\cmsis_core\source\core_cmFunc.h

[cc] Parsing ..\..\..\components\coocox-master\cmsis_core\source\core_cm4_simd.h

[cc] Parsing ..\..\..\components\coocox-master\C_library\source\syscalls.c

[cc] 5 files are up to date.

[cc] 0 files to be recompiled from dependency analysis.

[cc] 1 total files to be compiled.

[cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -g2 -Wall -O0 -c -DSTM32F411RET6 '-IC:\Users\Utilisateur\Desktop\essai nucleo' '-IC:\Users\Utilisateur\Desktop\essai nucleo\essai nucleo\components\coocox-master\cmsis_core\source' -IC:\Users\Utilisateur\Desktop '-IC:\Users\Utilisateur\Desktop\essai nucleo\essai nucleo\components\coocox-master\Semihosting' '-IC:\Users\Utilisateur\Desktop\essai nucleo\essai nucleo\components\coocox-master\cmsis_core' '-IC:\Users\Utilisateur\Desktop\essai nucleo\essai nucleo' '-IC:\Users\Utilisateur\Desktop\essai nucleo\essai nucleo\components\coocox-master\Semihosting\source' '-IC:\Users\Utilisateur\Desktop\essai nucleo\essai nucleo\components\coocox-master' ''C:\Users\Utilisateur\Desktop\essai nucleo\essai nucleo\app\main.c''

[cc] 0 total files to be compiled.

[cc] Starting link

[cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -g2 '-Wl,-Map=essai nucleo.map' -O0 -Wl,--gc-sections '-LC:\Users\Utilisateur\AppData\Roaming\CooCox\CoIDE\configuration\ProgramData\essai nucleo' '-Wl,-TC:\Users\Utilisateur\AppData\Roaming\CooCox\CoIDE\configuration\ProgramData\essai nucleo/link.ld' -g -o ''essai nucleo.elf'' ..\obj\syscalls.o ..\obj\stm32f4xx_gpio.o ..\obj\stm32f4xx_rcc.o ..\obj\semihosting.o ..\obj\sh_cmd.o ..\obj\main.o

Program Size:

text data bss dec hex filename

424 1084 68 1576 628 essai nucleo.elf

BUILD SUCCESSFUL

Total time: 4 seconds

Why does it say 

[cc] 0 files to be recompiled from dependency analysis.

[cc] 1 total files to be compiled.

or even [cc] 0 total files to be compiled.????

Is it normal ?

Posted on October 17, 2017 at 08:30

If I remember correctly, Coocox is basically dead.

I guess it does not support the latest STLink versons.

You could try some other free Toolchains for Windoze, like EmBitz or SW4STM32.

The ability to debug is sometimes essential.

[cc] 0 files to be recompiled from dependency analysis.

[cc] 1 total files to be compiled.

or even [cc] 0 total files to be compiled.????

The normal 'make' behaviour.

If you did not change the sources in the meantime, the compiled object is already up to date.

You will see the build time difference once you deal with larger projects containing dozen/hundreds of source modules ...

Posted on October 17, 2017 at 17:25

For a functional IDE try something like Keil, I don't have time to uphill ski issues with CooCox

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Benoît Bousquet
Associate II
Posted on October 18, 2017 at 10:16

Thanks ! I'm trying with

SW4STM32. For the moment, I am struggling making it work. You'll be in touch.