PlatformIO and Arduino IDE compilation results are different

Hello everyone, when I compile this code under arduino IDE, it can compile successfully.

#include "Arduino.h"
uint32_t now, receiver_input1, receiver_input1_previous;

void setup() {
  Serial.begin(57600);                                               //Start serial port at 57600bps
  attachInterrupt(PB10, receiver_ch1, CHANGE);                       //将PB10连接到例行接收器ch1

void loop() {
  delayMicroseconds(3500);                                           //等待我们模拟一个250Hz的刷新率
  Serial.println(receiver_input1);                                   //Print the receiver input to the serial monitor

void receiver_ch1() {
  now = micros();                                                    //存储当前micros()值
  if (0B1 & GPIOB_BASE->IDR >> 10 )receiver_input1_previous = now;   //如果输入PB10高,开始测量时间
  else receiver_input1 = now - receiver_input1_previous;             //如果输入PB10低,计算总脉冲时间

but when I compile under PlatformIO, the following error appears.

Processing nucleo_f446re (platform: ststm32; board: nucleo_f446re; framework: arduino)
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: ST STM32 (8.0.0) > ST Nucleo F446RE
HARDWARE: STM32F446RET6 180MHz, 128KB RAM, 512KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink)
 - framework-arduinoststm32 4.10900.200819 (1.9.0) 
 - framework-cmsis 2.50501.200527 (5.5.1) 
 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 18 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/nucleo_f446re/src/main.cpp.o
src/main.cpp: In function 'void receiver_ch1()':
src/main.cpp:7:23: error: base operand of '->' is not a pointer
    7 |   if (0B1 & GPIOB_BASE->IDR >> 10 )receiver_input1_previous = now;   //如果输入PB10高,开始测量时间
      |                       ^~
*** [.pio/build/nucleo_f446re/src/main.cpp.o] Error 1
=============================================================== [FAILED] Took 4.78 seconds ===============================================================
The terminal process "platformio 'run', '--environment', 'nucleo_f446re'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Looking forward to your reply :slight_smile:


since you’re using a different IDE, it’s Arduino.h doesn’t define GPIOB_BASE in the same way as on the Arduino IDE (is not a pointer)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.