This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: 如何获取供电电压

Part Number: CC2340R5

使用:BatteryMonitor.h

函数里面调用,

#include <ti/drivers/BatteryMonitor.h>

BatteryMonitor_init();

currentVoltage = BatteryMonitor_getVoltage();

编译报错:

undefined first referenced
symbol in file
--------- ----------------
BatMonSupportLPF3_config C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/drivers/lib/ticlang/m0p/drivers_cc23x0r5.a<BatMonSupportLPF3.c.obj>

想要获取供电电压,目前这样操作是合理的啊?是否有其他方法可以获取到供电电压。

  • 您好,

    目前这样操作是合理的啊?

    可以的。

    根据错误,检查编译器和链接器中是否包含头文件路径;并检查 BatMonSupportLPF3_config 是否定义(可能只是声明了但没有定义),定义了才会分配内存。

    点击此链接访问总体概述:https://c-faq.com/decl/decldef.html

    可能是链接器没有找到函数定义。

  • C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/drivers/lib/ticlang/m0p/drivers_cc23x0r5.a<BatMonSupportLPF3.c.obj>

      这个应该是驱动里面的问题,这个是.a文件里面,BatMonSupportLPF3_config  我应该怎么定义, 是什么类型的呢

  • 您可以尝试删除源文件中的 extern

  • 这个不是在.a里面吗?我在工程里面都找不到BatMonSupportLPF3_config这个呢。

  • C:\ti\simplelink_lowpower_f3_sdk_7_20_01_10\source\ti\drivers\batterymonitor\BatMonSupportLPF3.c

    修改如下

    //extern const BatMonSupportLPF3_Config BatMonSupportLPF3_config;
    const BatMonSupportLPF3_Config BatMonSupportLPF3_config;

     但是还是编译报错。

  • 题目中的错误表明在编译过程中找不到符号 BatMonSupportLPF3_config 的定义,可能是由于链接时缺少对相应的库或资源文件引起的。

    您先查看一下 Include Options 里面是否包含了该路径:C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/drivers/lib/ticlang/m0p/drivers_cc23x0r5.a<BatMonSupportLPF3.c.obj>

    另外您使用的哪一个例程,能否把详细的报错信息贴上来。

  • C:\ti\simplelink_lowpower_f3_sdk_7_20_01_10\examples\rtos\LP_EM_CC2340R5\ble5stack\basic_ble

    **** Build of configuration Release for project basic_ble_LP_EM_CC2340R5_freertos_ticlang ****
    
    "C:\\ti\\ccs1240\\ccs\\utils\\bin\\gmake" -k -j 8 all -O 
     
    Building file: "C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/bleapp/ble_app_util/src/bleapputil_task.c"
    Invoking: Arm Compiler
    "C:/ti/ccs1240/ccs/tools/compiler/ti-cgt-armllvm_3.2.0.LTS/bin/tiarmclang.exe" -c @"D:/workspace/0038_TI/workspace/basic_ble_LP_EM_CC2340R5_freertos_ticlang/Release/syscfg/ti_ble_app_config.opt" @"D:/workspace/0038_TI/workspace/basic_ble_LP_EM_CC2340R5_freertos_ticlang/Release/syscfg/ti_build_config.opt" @"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/config/build_components.opt" @"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/config/factory_config.opt"  -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -Oz -I"D:/workspace/0038_TI/workspace/basic_ble_LP_EM_CC2340R5_freertos_ticlang" -I"D:/workspace/0038_TI/workspace/basic_ble_LP_EM_CC2340R5_freertos_ticlang/Release" -I"D:/workspace/0038_TI/workspace/basic_ble_LP_EM_CC2340R5_freertos_ticlang/app" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/controller/cc26xx/inc" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/inc" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/rom" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/common/cc26xx" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/icall/inc" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/hal/src/target/_common" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/common/cc26xx/npi/stack" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/hal/src/inc" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/heapmgr" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/profiles/dev_info" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/profiles/simple_profile" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/icall/src/inc" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/npi/src" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/osal/src/inc" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/services/src/saddr" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/services/src/sdata" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/common/nv" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/common/cc26xx" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/icall/src" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/devices/cc23x0r5" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/devices/cc23x0r5/settings" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/drivers/rcl" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/boards/cc23x0r5" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/posix/ticlang" -I"D:/workspace/0038_TI/FreeRTOSv202212.01/FreeRTOS/Source/include" -I"D:/workspace/0038_TI/FreeRTOSv202212.01/FreeRTOS/Source/portable/GCC/ARM_CM0" -I"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/kernel/freertos" -DICALL_NO_APP_EVENTS -DCC23X0 -DNVOCMP_NWSAMEITEM=1 -DFLASH_ONLY_BUILD -DUSE_RCL -DFREERTOS -DNVOCMP_POSIX_MUTEX -gdwarf-3 -ffunction-sections -MMD -MP -MF"common/BLEAppUtil/bleapputil_task.d_raw" -MT"common/BLEAppUtil/bleapputil_task.o" -I"D:/workspace/0038_TI/workspace/basic_ble_LP_EM_CC2340R5_freertos_ticlang/Release/syscfg" -std=c99 @"syscfg/ti_build_config.opt" @"syscfg/ti_ble_app_config.opt" @"syscfg/ti_utils_build_compiler.opt"  -o"common/BLEAppUtil/bleapputil_task.o" "C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/bleapp/ble_app_util/src/bleapputil_task.c"
    Finished building: "C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/bleapp/ble_app_util/src/bleapputil_task.c"
     
    Building target: "basic_ble_LP_EM_CC2340R5_freertos_ticlang.out"
    Invoking: Arm Linker
    "C:/ti/ccs1240/ccs/tools/compiler/ti-cgt-armllvm_3.2.0.LTS/bin/tiarmclang.exe" @"D:/workspace/0038_TI/workspace/basic_ble_LP_EM_CC2340R5_freertos_ticlang/Release/syscfg/ti_ble_app_config.opt" @"D:/workspace/0038_TI/workspace/basic_ble_LP_EM_CC2340R5_freertos_ticlang/Release/syscfg/ti_build_config.opt" @"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/config/build_components.opt" @"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/config/factory_config.opt"  -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -Oz -DICALL_NO_APP_EVENTS -DCC23X0 -DNVOCMP_NWSAMEITEM=1 -DFLASH_ONLY_BUILD -DUSE_RCL -DFREERTOS -DNVOCMP_POSIX_MUTEX -gdwarf-3 -ffunction-sections -Wl,-m"basic_ble_LP_EM_CC2340R5_freertos_ticlang.map" -Wl,-i"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source" -Wl,-i"D:/workspace/0038_TI/workspace/basic_ble_LP_EM_CC2340R5_freertos_ticlang/Release/syscfg" -Wl,-i"C:/ti/ccs1240/ccs/tools/compiler/ti-cgt-armllvm_3.2.0.LTS/lib" -Wl,--reread_libs -Wl,--diag_wrap=off -Wl,--display_error_number -Wl,--warn_sections -Wl,--xml_link_info="basic_ble_LP_EM_CC2340R5_freertos_ticlang_linkInfo.xml" -Wl,--rom_model -o "basic_ble_LP_EM_CC2340R5_freertos_ticlang.out" "./syscfg/ti_ble_config.o" "./syscfg/ti_devices_config.o" "./syscfg/ti_drivers_config.o" "./syscfg/ti_freertos_config.o" "./syscfg/ti_freertos_portable_config.o" "./main_freertos.o" "./Startup/rcl_settings_ble.o" "./app/Profiles/app_dev_info.o" "./app/Profiles/app_simple_gatt.o" "./app/app_broadcaster.o" "./app/app_central.o" "./app/app_connection.o" "./app/app_data.o" "./app/app_main.o" "./app/app_menu.o" "./app/app_observer.o" "./app/app_pairing.o" "./app/app_peripheral.o" "./common/BLEAppUtil/bleapputil_init.o" "./common/BLEAppUtil/bleapputil_process.o" "./common/BLEAppUtil/bleapputil_stack_callbacks.o" "./common/BLEAppUtil/bleapputil_task.o" "./common/Drivers/NV/crc.o" "./common/Drivers/NV/nvocmp.o" "./common/MenuModule/menu_module.o" "./common/Profiles/simple_gatt/simple_gatt_profile.o" "./common/Services/dev_info/dev_info_service.o" "./common/Startup/ble_user_config_stack.o" "./common/Startup/osal_icall_ble.o" "./common/Startup/rom_init.o" "./common/iCall/icall_POSIX.o" "./common/iCall/icall_cc23x0.o" "./common/iCall/icall_user_config.o" "./common/iCallBLE/ble_stack_api.o" "./common/iCallBLE/ble_user_config.o" "./common/iCallBLE/icall_api_lite.o" "../cc23x0_app_freertos.cmd"  -Wl,-l"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/third_party/spiffs/lib/ticlang/m0p/spiffs.a" -Wl,-l"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/drivers/rcl/lib/ticlang/m0p/rcl_cc23x0r5.a" -Wl,-l"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/drivers/lib/ticlang/m0p/drivers_cc23x0r5.a" -Wl,-l"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/display/lib/ticlang/m0p/display_cc23x0r5.a" -Wl,-l"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/third_party/ecc/lib/ticlang/m0p/ecc.a" -Wl,-l"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/devices/cc23x0r5/rf_patches/lib/ticlang/lrf_cc23x0r5.a" -Wl,-l"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/lib_projects/CC2340R5/OneLib/lib/ticlang/m0p/OneLib.a" -Wl,-l"C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/ble5stack_flash/lib_projects/CC2340R5/StackWrapper/lib/ticlang/m0p/StackWrapper.a" -Wl,-l"ti/devices/cc23x0r5/driverlib/lib/ticlang/driverlib.a" -Wl,-llibc.a 
    makefile:201: recipe for target 'basic_ble_LP_EM_CC2340R5_freertos_ticlang.out' failed
     
     undefined                first referenced                                                                                                         
      symbol                      in file                                                                                                              
     ---------                ----------------                                                                                                         
     BatMonSupportLPF3_config C:/ti/simplelink_lowpower_f3_sdk_7_20_01_10/source/ti/drivers/lib/ticlang/m0p/drivers_cc23x0r5.a<BatMonSupportLPF3.c.obj>
     
    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "basic_ble_LP_EM_CC2340R5_freertos_ticlang.out" not built
    tiarmclang: error: tiarmlnk command failed with exit code 1 (use -v to see invocation)
    gmake[1]: *** [basic_ble_LP_EM_CC2340R5_freertos_ticlang.out] Error 1
    makefile:197: recipe for target 'all' failed
    gmake: *** [all] Error 2

  • 您的问题解决了吗?

  • 最后是要cfg里面增加驱动,即可。问题已经解决