STM32F103RCTx-TLE5012B-Magnetic-Angle-Sensor
STM32F103RCTx-TLE5012B-Magnetic-Angle-Sensor copied to clipboard
:kiwi_fruit: TLE5012B-Magnetic-Angle-Sensor For STM32F103RCTx
:beers: F103RCTx_TLE5012B 
/*
* ___ ___ ___ ___ ___ ___
* ___ /__/\ / /\ ___ /__/\ / /\ / /\ /__/\
* / /\ \ \:\ / /:/_ / /\ \ \:\ / /:/_ / /::\ \ \:\
* / /:/ \ \:\ / /:/ /\ / /:/ \ \:\ / /:/ /\ / /:/\:\ \ \:\
* /__/::\ _____\__\:\ / /:/ /:/ /__/::\ _____\__\:\ / /:/ /:/_ / /:/ \:\ _____\__\:\
* \__\/\:\__ /__/::::::::\ /__/:/ /:/ \__\/\:\__ /__/::::::::\ /__/:/ /:/ /\ /__/:/ \__\:\ /__/::::::::\
* \ \:\/\ \ \:\~~\~~\/ \ \:\/:/ \ \:\/\ \ \:\~~\~~\/ \ \:\/:/ /:/ \ \:\ / /:/ \ \:\~~\~~\/
* \__\::/ \ \:\ ~~~ \ \::/ \__\::/ \ \:\ ~~~ \ \::/ /:/ \ \:\ /:/ \ \:\ ~~~
* /__/:/ \ \:\ \ \:\ /__/:/ \ \:\ \ \:\/:/ \ \:\/:/ \ \:\
* \__\/ \ \:\ \ \:\ \__\/ \ \:\ \ \::/ \ \::/ \ \:\
* \__\/ \__\/ \__\/ \__\/ \__\/ \__\/
*/
:book: 简介
这是英飞凌 360° 磁角度传感器 TLE5012B
的测试验证工程,移植了英飞凌 TLE5012B :package: 官方 Github 仓库 上的 C++ 代码到 STM32 平台,具体涉及到的文件为以下两个,其它文件为使用 3-Wire
方式进行通讯时才需要:
:warning: 本仓库当前对应官方仓库的历史 Commit 为 5249d6293d2a88779bb38e815aec26316db00599
- :file_folder: Tle5012b_4wire.h
- :file_folder: Tle5012b_4wire.cpp
初次验证该传感器功能时,使用了官方的 Angle Sensor 2GO Kit 系列套件的 TLE5012B_E1000_MS2GO,配合附带的上位机程序进行了测试。
![]() |
![]() |
---|---|
Bulk Sensor 散片 | Sensor2Go kit |
:pushpin: Angle-Sensor-2GO-Kit 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 及以上