Blink not working on STM32G491 Nucleo board

All about boards manufactured by ST
RaceAgainstTime
Posts: 7
Joined: Wed Mar 20, 2024 8:01 pm

Blink not working on STM32G491 Nucleo board

Post by RaceAgainstTime »

Hi,

Have been trying to get the blink sketch to work on my STM32G491 Nucleo board (NUCLEO-G491RE), but it refuses to work, although the board programs successfully.

Tools Version
Arduino IDE : 2.3.2
Core: STM32 MCU Based Boards by STMicroelectronics v2.7.1

output log
Sketch uses 15988 bytes (3%) of program storage space. Maximum is 524288 bytes.
Global variables use 1288 bytes (0%) of dynamic memory, leaving 129784 bytes for local variables. Maximum is 131072 bytes.
-------------------------------------------------------------------
STM32CubeProgrammer v2.15.0
-------------------------------------------------------------------

ST-LINK SN : 002400293532510531333430
ST-LINK FW : V3J13M4
Board : NUCLEO-G491RE
Voltage : 3.29V
SWD freq : 8000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x479
Revision ID : Rev Z
Device name : STM32G491xC/E
Flash size : 512 KBytes
Device type : MCU
Device CPU : Cortex-M4
BL Version : 0xD2



Memory Programming ...
Opening and parsing file: Blink.ino.bin
File : Blink.ino.bin
Size : 16.10 KB
Address : 0x08000000


Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 8]
Download in Progress:


File download complete
Time elapsed during download operation: 00:00:00.584

RUNNING Program ...
Address: : 0x8000000
Application is running, Please Hold on...
Start operation achieved successfully

Code: Select all

#define LED_BUILTIN PA5

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}
The PA5 pin is given in the board's user manual STM32G4 Nucleo-64 boards (MB1367).
LD2 USER
This green LED is a user LED connected to STM32G4 I/O PA5 (SB6 ON) corresponding to the ARDUINO® D13.
To light LED LD2, a high logic state “1” must be written in the corresponding GPIO PA5. A transistor is used to
drive the LED LD2. LD2 consumption does not impact the VDD STM32G4 power measurement, since LD2 is
isolated from it.
Settings attached.
stm32g491 settings.png
stm32g491 settings.png (63.86 KiB) Viewed 381 times
Any tips on getting it to work would be highly appreciated.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Blink not working on STM32G491 Nucleo board

Post by fpiSTM »

Maybe system core clock config failed. You should try to debug to see if you reach error_handler.
RaceAgainstTime
Posts: 7
Joined: Wed Mar 20, 2024 8:01 pm

Re: Blink not working on STM32G491 Nucleo board

Post by RaceAgainstTime »

Hi
And how does one debug, I don't have any clock initialisation in the sketch, i think that's handled in the "generic_clock.c" file, do I need to open it in a new tab?
Also when I run the debugger I can see only the Pause, Restart and Stop button active , the single step buttons are disabled.
stm32g491 debug.png
stm32g491 debug.png (27.21 KiB) Viewed 351 times
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Blink not working on STM32G491 Nucleo board

Post by fpiSTM »

If you pause you should see where you are. If in error handler the the clock config fails.
RaceAgainstTime
Posts: 7
Joined: Wed Mar 20, 2024 8:01 pm

Re: Blink not working on STM32G491 Nucleo board

Post by RaceAgainstTime »

Hi,
If I pause, the call stack shows this
stm32g491 debug 2.png
stm32g491 debug 2.png (66.2 KiB) Viewed 279 times
Is it something to do with incorrect Watchdog initialisation?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Blink not working on STM32G491 Nucleo board

Post by fpiSTM »

No. My guess is that error handler is called during the clock config. You can redefine it at sketch level.
https://github.com/stm32duino/Arduino_C ... lock.c#L24

Replace WEAK by extern "C"
Then you could easily add a breakpoint.
Finally you could use CubeMx to generate one.
RaceAgainstTime
Posts: 7
Joined: Wed Mar 20, 2024 8:01 pm

Re: Blink not working on STM32G491 Nucleo board

Post by RaceAgainstTime »

Hi,

I followed the given instructions and pasted the clock init code from generic_clock.c into my sketch.
After entering debugging it doesn't hit the breakpoint.
On pausing the debugger I get the same WWDG location.
stm32g491 debug 3.png
stm32g491 debug 3.png (80.56 KiB) Viewed 257 times
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Blink not working on STM32G491 Nucleo board

Post by fpiSTM »

did you build with Optimize for debug selected in the menu ?
RaceAgainstTime
Posts: 7
Joined: Wed Mar 20, 2024 8:01 pm

Re: Blink not working on STM32G491 Nucleo board

Post by RaceAgainstTime »

fpiSTM wrote: Sat Mar 23, 2024 7:28 am did you build with Optimize for debug selected in the menu ?
No that was disabled.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Blink not working on STM32G491 Nucleo board

Post by fpiSTM »

Try with it enabled else you don't have the symbol for debugging.
Post Reply

Return to “STM boards (Discovery, Eval, Nucleo, ...)”