STM32通过UART读取Trinamic TMC2209失败求助
单UART半双工控制TMC2209通信异常求助
我已为此问题困扰许久,目前能找到的TMC2209驱动相关STM32资源极少。我可以通过STEP/DIR接口正常使用设备,但希望仅通过单UART线路实现高级功能,不再依赖STEP/DIR线路。我正尝试以无库的基础形式控制TMC2209,理解原理后自行构建代码,当前目标是实现通信并驱动其转动。
我使用STM32F103,将USART3(PC10)配置为单线半双工模式,通过以下代码尝试读取CHOPCONF寄存器:
Sync = 0x05; // sync byte to start the Tx Address = 0x00; // MS1 and MS2 are pulled low so the device address is 0 RegAddress = 0x6C; // Trying for a basic read from the CHOPCONF Reg motor_CRC = 0xCA; // CRC that has been worked out HAL_UART_Transmit(&huart3,&Sync,sizeof(Sync),20); HAL_UART_Transmit(&huart3,&Address,sizeof(Address),20); HAL_UART_Transmit(&huart3,&RegAddress,sizeof(RegAddress),20); HAL_UART_Transmit(&huart3,&motor_CRC,sizeof(motor_CRC),20); // Receive the data from the TMC2209 HAL_UART_Receive(&huart3, &ReplySync, sizeof(ReplySync), 200); HAL_UART_Receive(&huart3, &ReplyMasterAddr, sizeof(ReplyMaster), 20); HAL_UART_Receive(&huart3, &ReplyAddr, sizeof(ReplyAddr), 20); HAL_UART_Receive(&huart3, &Reply1, sizeof(Reply1), 20); HAL_UART_Receive(&huart3, &Reply2, sizeof(Reply2), 20); HAL_UART_Receive(&huart3, &Reply3, sizeof(Reply3), 20); HAL_UART_Receive(&huart3, &Reply4, sizeof(Reply4), 20); HAL_UART_Receive(&huart3, &ReplyCRC, sizeof(ReplyCRC), 20); HAL_Delay(1000);
预期返回结果(依据数据手册):
ReplySync >>> 0x05 ReplyMasterAddr>>> 0xFF ReplyAddr >>> 0xCA Reply1 >>> 0x53 Reply2 >>> 0x00 Reply3 >>> 0x00 Reply4 >>> 0x10 ReplyCRC >>> I dont know this one yet,,,,
实际返回结果:
ReplySync >>> 0x05 ReplyMasterAddr>>> 0x00 ReplyAddr >>> 0x5D Reply1 >>> 0x09 Reply2 >>> 0x08 Reply3 >>> 0x00 Reply4 >>> 0x02 ReplyCRC >>> 0x09
我不确定是否发送顺序有误,或是否不应使用HAL函数实现该功能,恳请提供帮助或方向指引。
内容的提问来源于stack exchange,提问作者Spider999
相关产品推荐
相关产品推荐

