platformio / platform-ststm32

ST STM32: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/ststm32
Apache License 2.0
407 stars 312 forks source link

nucleo_f429, hardwareSerial.available(), debug optimization "-O0 -g" do not work together. #679

Open KoolElmout opened 1 year ago

KoolElmout commented 1 year ago

Hello everyone,

I have discovered something strange to me which i haven't found any explanation on the web. I move my code from ststm32 15.3.0 to 15.4.1. My code was working fine either in debug or in release with the 15.3.0.

The problem:

My question I am used to have the -g -O0 for debugging to be able to have a true step by step across my code. I do not understand what happened here. I would like to understand why the non optimization asked will interfere with the available() functionality. Do you have some explanation ?.

Thank in advance. Julien

Information:

Here is my platform.ini before the rectification [env:nucleo_f429zi] platform = ststm32 board = nucleo_f429zi framework = arduino debug_build_flags = -g -O0 <<=== I had to comment this line for the available() function to work. lib_deps = adafruit/Adafruit INA219@^1.2.0 extra_scripts = pre_generateBuildDate.py

Partial Code

#define BAUDRATE 115200
#define rs485_rx_pin PG9   // Arduino D0 //USART6
#define rs485_tx_pin PG14  // Arduino D1

HardwareSerial* uart;
void setup() {
    uart = new HardwareSerial(rs485_rx_pin, rs485_tx_pin);
    uart->begin(BAUDRATE);
}

void loop() {
   if (uart->available() > 0) {  //<== This available function does not work when using debug non optimization
          rxb = (uint8_t)uart->read();
    ...
    }
}