Target Halted Due to debug-request

You cannot (should not if you want it to work) use GPIO_PIN_X values from the STM32HAL for the digtialWrite() or pinMode functions of Arduino. Also this would be missing which GPIO bank it is. Like GPIOA and pin 13 is PA13, but how is only with the pin info supposed to know if you don’t want PC13?

The pinMode and digitalWrite and friends functions go through a pin mapping that turns an absolute pin number / macro into the port + pin information, e.g. “17” = PC12.

The exact pin name to numbers mapping can be seen at

https://github.com/stm32duino/Arduino_Core_STM32/blob/master/variants/NUCLEO_F302R8/variant.h#L93-L95

https://github.com/stm32duino/Arduino_Core_STM32/blob/master/variants/NUCLEO_F302R8/variant.h#L43-L43

say that LED_BUILTIN maps to pin PB13.

This matches the information found on NUCLEO-F302R8 | Mbed (CN5 connector).

for this particular variant.

However, you should never use the numerical values directly. Always their symbolic name.

The Nucleo F302R8, as the on board LED pin on D13 (arduino pin name) or PB13. The LED is also mapped to the LED_BUILTIN macro.

So please try this code @udit8348

#include <Arduino.h>

//#define LED LED_BUILTIN
#define LED PB13

void setup() {
  pinMode(LED, OUTPUT);
}

void loop() {
  digitalWrite(LED, LOW);
  delay(1000);
  digitalWrite(LED, HIGH);
  delay(1000);
}

Either macro value works.

1 Like