项目作者: SummerFalls

项目描述 :
:kiwi_fruit: TLE5012B-Magnetic-Angle-Sensor For STM32F103RCTx
高级语言: C
项目地址: git://github.com/SummerFalls/STM32F103RCTx-TLE5012B-Magnetic-Angle-Sensor.git


" class="reference-link">:beers: F103RCTx_TLE5012B

  1. /*
  2. * ___ ___ ___ ___ ___ ___
  3. * ___ /__/\ / /\ ___ /__/\ / /\ / /\ /__/\
  4. * / /\ \ \:\ / /:/_ / /\ \ \:\ / /:/_ / /::\ \ \:\
  5. * / /:/ \ \:\ / /:/ /\ / /:/ \ \:\ / /:/ /\ / /:/\:\ \ \:\
  6. * /__/::\ _____\__\:\ / /:/ /:/ /__/::\ _____\__\:\ / /:/ /:/_ / /:/ \:\ _____\__\:\
  7. * \__\/\:\__ /__/::::::::\ /__/:/ /:/ \__\/\:\__ /__/::::::::\ /__/:/ /:/ /\ /__/:/ \__\:\ /__/::::::::\
  8. * \ \:\/\ \ \:\~~\~~\/ \ \:\/:/ \ \:\/\ \ \:\~~\~~\/ \ \:\/:/ /:/ \ \:\ / /:/ \ \:\~~\~~\/
  9. * \__\::/ \ \:\ ~~~ \ \::/ \__\::/ \ \:\ ~~~ \ \::/ /:/ \ \:\ /:/ \ \:\ ~~~
  10. * /__/:/ \ \:\ \ \:\ /__/:/ \ \:\ \ \:\/:/ \ \:\/:/ \ \:\
  11. * \__\/ \ \:\ \ \:\ \__\/ \ \:\ \ \::/ \ \::/ \ \:\
  12. * \__\/ \__\/ \__\/ \__\/ \__\/ \__\/
  13. */

:book: 简介



Infineon_Logo

这是英飞凌 360° 磁角度传感器 TLE5012B 的测试验证工程,移植了英飞凌 TLE5012B :package: 官方 Github 仓库 上的 C++ 代码到 STM32 平台,具体涉及到的文件为以下两个,其它文件为使用 3-Wire 方式进行通讯时才需要:

:warning: 本仓库当前对应官方仓库的历史 Commit 为 5249d6293d2a88779bb38e815aec26316db00599

初次验证该传感器功能时,使用了官方的 Angle Sensor 2GO Kit 系列套件的 TLE5012B_E1000_MS2GO,配合附带的上位机程序进行了测试。



| TLE5012B_BulkSensor | TLE5012B_E1000_MS2GO_Pic |
|:—————————————————————-:|:——————————————————————————-:|
| Bulk Sensor 散片 | Sensor2Go kit |

:pushpin: Angle-Sensor-2GO-Kit Pin Out

TLE5012B_E1000_MS2GO_PIN_OUT

:pushpin: MCU 引脚分配图

引脚分配

:warning: 注意

接线方式选择了官方手册当中的 推挽输出 方式,达 8 MBits/s,而 开漏输出 方式的接线不一样,且速率也为 2 MBits/s。

按照官方仓库中 README.md 文档 以及该仓库下的 #1 Issue: Example connection scheme for tle5012be1000 chip and microcontorller,还有 STM32 论坛 的说法测试了在 MOSI 脚串接了一个 4.7K 电阻,如下图,发现数据通讯并不正常,待进一步验证测试。

硬件接线图

最后选择了 #1 Issue: Example connection scheme for tle5012be1000 chip and microcontorller 中的不串接电阻,通过代码控制 MOSI 脚对应的 GPIO 口的状态实现了数据的正常通讯(SPI 发送 Command 命令字之后,将 MOSI 脚的 GPIO 切换为高阻态(浮空输入),再进行接收数据字和安全字,接收完毕后再切换回复用推挽输出

:speech_balloon: 以下为以上 Issue 中英飞凌官方仓库维护人员 MorganSandercock 的原话

Yes…
connect CSQ(3) to any convenient uC pin to use as chip-select
connect DATA(4) to MISO
connect SCK(2) to SCK
connect DATA(4) to MOSI via a resistor. Use anything between 3.3K and 10K.

If you don’t use a resistor between DATA and MOSI then it is possible to modify the library to put MOSI into a high-impedance state after writing the command word and before reading the response. Setting it back to SPI output mode depends on the specific microcontroller, so this is not a simple one-line change to the library.

:gear: 硬件 & 软件 需求

硬件需求

  • STM32F103RCT6 PCB Board
  • J-Link V9

软件需求

  • Keil uVision5.27 及以上
  • STM32CubeMX 5.6.1 及以上

:books: 参考资料

  1. TLE5012B 磁角度传感器官网介绍页面
  2. TLE5012B 用户手册
  3. Angle Sensor 2GO Kit 系列套件
  4. TLE5012B_E1000_MS2GO 评估板
  5. 官方 TLE5012B Github 代码仓库
  6. 官方 TLE5012B Github 代码仓库关于MOSI脚串接电阻的 Issue
  7. STM32 论坛中关于 Bulk Sensor 接线的原理图和源码