STM32F103移植mpu9250


1. 需求和来源

回归技术的第二天,需要对机器人下层执行器做优化
外设不算多,用STM32F103C8T6刚刚好留一个测试引脚
但是在网上找不到比较好的mpu9250在STM32F103的应用例程
那就只能自己来了

直接移植正点原子阿波罗F429的mpu9250例程
简单的移植,修改相关文件和添加头文件包含之类,的就不多说
就是说说过程中会碰到的一些问题


1.1. 基本配置

在这里插入图片描述

  1. 按F429例程添加预定义宏:
    USE_HAL_DRIVER,STM32F429xx,MPL_LOG_NDEBUG=1,EMPL,MPU9250,EMPL_TARGET_STM32F4
    
  2. 修改编译优化等级
  3. MPL 代码,要求在 MDK Options for TargetC/C++选项卡里面要勾选 C99 模式,否则编译出错

1.2. 遗留问题

之后就会遇到网上或者一些教程上比较少提到的问题

  1. 出现下列错误:

    .\Obj\Project.axf: Error: L6366E: compass_vec_cal.o attributes are not compatible with the provided attributes .
    Object compass_vec_cal.o contains Build Attributes that are incompatible with the provided attributes.
        Tag_CPU_arch = ARM v7E-M (=13)
    ...
    .\Obj\Project.axf: Error: L6366E: accel_auto_cal.o attributes are not compatible with the provided attributes .
    Object accel_auto_cal.o contains Build Attributes that are incompatible with the provided attributes.
        Tag_CPU_arch = ARM v7E-M (=13)
    Not enough information to list image symbols.
    Not enough information to list the image map.
    

    F4例程里面的libmpllib.lib这个库文件是不是针对F4生成的,F1不能直接使用
    在这里插入图片描述

  2. 出现下列错误:

    .\Obj\Project.axf: Error: L6406E: No space in execution regions with .ANY selector matching empl_outputs.o(i.inv_enable_eMPL_outputs).
    .\Obj\Project.axf: Error: L6406E: No space in execution regions with .ANY selector matching data_builder.o(i.inv_get_gyro_bias).
    ...
    .\Obj\Project.axf: Error: L6406E: No space in execution regions with .ANY selector matching usenofp.o(x$fpl$usenofp).
    .\Obj\Project.axf: Error: L6407E: Sections of aggregate size 0xaa4 bytes could not fit into .ANY selector(s).
    

    编译通过、在链接时会提示以下错误信息提示空间不够


2. 解决办法


2.1. libmpllib.lib

在正点原子的资料包里找到适用于F1的libmpllib.lib
硬件资料->MPU9250资料->motion_driver_6.12.zip->mpl libraries->arm->keil->libmpllib_Keil_M3.zip
使用这个lib替换掉原来


2.2. 空间不够

一般使用微库就能解决
将以更精简短小的C库替代标准C库,减小代码大小,使用微库的方法如下:
打开Project->Options->Target,将Use MicroLIB前面的复选框勾上

在这里插入图片描述

其他什么特别的,基本在网上能轻松找到。
还是可以移植成功的,利用串口发送一下姿态角
在这里插入图片描述
因为受到文件监控,这个软件工程就不能直接分享了。


谢谢

发布了217 篇原创文章 · 获赞 290 · 访问量 288万+

猜你喜欢

转载自blog.csdn.net/qq_32618327/article/details/103380212