PlatformIO and Arduino IDE compilation results are different
Posted: Sat Mar 06, 2021 3:03 pm
Hello everyone, when I compile this code under arduino IDE, it can compile successfully.
but when I compile under PlatformIO, the following error appears.
Looking forward to your reply 
Code: Select all
#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); //Connect changing PB10 to routine receiver_ch1
}
void loop() {
delayMicroseconds(3500); //Wait 3500us to simulate a 250Hz refresh rate
Serial.println(receiver_input1); //Print the receiver input to the serial monitor
}
void receiver_ch1() {
now = micros(); //Store the current micros() value
if (0B1 & GPIOB_BASE->IDR >> 10 )receiver_input1_previous = now; //If input PB10 is high start measuring the time
else receiver_input1 = now - receiver_input1_previous; //If input PB10 is low calculate the total pulse time
}
Code: Select all
Processing genericSTM32F103ZE (platform: ststm32; board: genericSTM32F103ZE; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103ZE.html
PLATFORM: ST STM32 (8.0.0) > STM32F103ZE (64k RAM. 512k Flash)
HARDWARE: STM32F103ZET6 72MHz, 64KB RAM, 512KB Flash
DEBUG: Current (blackmagic) External (blackmagic, jlink, stlink)
PACKAGES:
- 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 -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 18 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/genericSTM32F103ZE/src/main.cpp.o
src/main.cpp: In function 'void setup()':
src/main.cpp:6:25: error: 'receiver_ch1' was not declared in this scope; did you mean 'receiver_input1'?
6 | attachInterrupt(PB10, receiver_ch1, CHANGE); //Connect changing PB10 to routine receiver_ch1
| ^~~~~~~~~~~~
| receiver_input1
src/main.cpp: In function 'void receiver_ch1()':
src/main.cpp:16:23: error: base operand of '->' is not a pointer
16 | if (0B1 & GPIOB_BASE->IDR >> 10 )receiver_input1_previous = now; //If input PB10 is high start measuring the time
| ^~
*** [.pio/build/genericSTM32F103ZE/src/main.cpp.o] Error 1
=============================================================== [FAILED] Took 3.95 seconds ===============================================================
The terminal process "platformio 'run'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
