B_G431B_ESC1 current sensor complie error

Dear Sir/madam,

I am using the B-G431B-ESC1 with the PlatformIO, and I’ve been able to get closed-loop control to work decently well. Next step, I wanted to implement current sensing and the foc_current torque controller. When i compile and updating the current sensor code. I still get the following compile error:

c:/users/daniel_huynh/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/disco_b_g431b_esc1/lib2e5/Simple FOC/current_sense/hardware_specific/stm32/b_g431/b_g431_mcu.cpp.o: in function `_configureOPAMP(OPAMP_HandleTypeDef*, OPAMP_TypeDef*)':
b_g431_mcu.cpp:(.text._Z15_configureOPAMPP19OPAMP_HandleTypeDefP13OPAMP_TypeDef+0x22): undefined reference to `HAL_OPAMP_Init'
c:/users/daniel_huynh/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/disco_b_g431b_esc1/lib2e5/Simple FOC/current_sense/hardware_specific/stm32/b_g431/b_g431_mcu.cpp.o: in function `_configureADCLowSide(void const*, int, int, int)':
b_g431_mcu.cpp:(.text._Z20_configureADCLowSidePKviii+0x7a): undefined reference to `HAL_OPAMP_Start'
c:/users/daniel_huynh/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: b_g431_mcu.cpp:(.text._Z20_configureADCLowSidePKviii+0x80): undefined reference to `HAL_OPAMP_Start'
c:/users/daniel_huynh/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: b_g431_mcu.cpp:(.text._Z20_configureADCLowSidePKviii+0x86): undefined reference to `HAL_OPAMP_Start'

I try to add the build flags option " -D HALL_OPAMP_MODULE_ENABLED" and “-D HAL_ADC_MODULE_ONLY”. Same error above.

This is my platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:disco_b_g431b_esc1]
platform = ststm32
board = disco_b_g431b_esc1
framework = arduino

upload_protocol = stlink

monitor_speed = 115200

build_flags = 
    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
	-D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF
	-D HALL_OPAMP_MODULE_ENABLED
	-D HAL_ADC_MODULE_ONLY

lib_deps = 
	https://github.com/simplefoc/Arduino-FOC.git
    SPI
    Wire
lib_archive = false

Noted: When i used the Arduino IDE. It’s working very well with -DHAL_OPAMP_MODULE_ENABLED flag.
With PlatformIO, I commented out the line “lib_archive = false”. There are no errors reported. However, the code doesn’t seem to be functioning properly.

Do you know this issue from platformIO?

if you look in the recent threads

I ran into a similar issue, see my compile error (first picture). I can compile if I remove “lib_archive = false”, but then the motor won’t initialize (second picture). Similar to you, I can compile in Arduino IDE

I found this error was already reported but not sure what is the solution: STM32G4xx current sensing can't compile (PlatformIO) · Issue #128 · simplefoc/Arduino-FOC · GitHub

Do you mind sharing your closed-loop code? Thanks.

Your problem is a typo, here, it is HAL, not HALL (reply to @promakina )

Thanks for sharing.
You’re corrected. Now, It’s working. ^^

1 Like