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.

[参考译文] LAUNCHCC3220MODASF:无法读取 UART

Guru**** 2483385 points
Other Parts Discussed in Thread: SYSCONFIG

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1280635/launchcc3220modasf-unable-to-read-uart

器件型号:LAUNCHCC3220MODASF
主题中讨论的其他器件:SysConfig

您好

我使用的是 simplelink_cc32xx_sdk_4_10_00_07和 CCS 12.0版。 尝试设置 Modbus (UART-485)代码写入功能成功、但我的代码在 rs 读取时卡住。
下面提到的代码

代码

void uart_init (uint32_t rate)
{
display_printf (display、0、0、"starting the UART MODBUS task\n");
UART_Params uartParams;
UART_Handle UART;
//初始化 UART 驱动程序
uart_init();
//使用默认值初始化 UART 参数
uart_params_init (&uartParams);
//设置 UART 参数
uartParams.readMode = UART_MODE_BLOCKING;
uartParams.writeMode = UART_MODE_BLOCKING;
uartParams.readTimeout = 1000;//设置所需的读取超时
uartParams.writeTimeout = 1000;//设置所需的写入超时
uartParams.readCallback = NULL;//如果使用回调模式、则设置为您的读取回调函数
uartParams.writeCallback = NULL;//如果使用回调模式、则设置为您的写回调函数
uartParams.readReturnMode = UART_RETURN_FULL;//如果使用基于换行的读取、则为 UART_RETURN_NEWLINE
uartParams.readDataMode = UART_DATA_binary;// Modbus 帧通常包含二进制数据
uartParams.writeDataMode = UART_DATA_binary;// Modbus 帧通常包含二进制数据
uartParams.readEcho = UART_echo_off;// Modbus 通信通常不需要回传
uartParams.baudrate =速率;//设置所需的波特率
uartParams.dataLength = UART_LEN_8;//每帧8位
uartParams.stopbits = UART_STOP_ONE;// 1个停止位
uartParams.parityType = UART_PAR_NONE;//无奇偶校验
uartParams.custom = NULL;//如果驱动程序实现需要,则设置为自定义参数。

//打开 UART 实例
uart = uart_open (CONFIG_UART_RS485、&uartParams);
if (uart == NULL){
Display_printf (display、0、0、"Error:unable to open UART");
返回;

UART_CONTROL (UART、UART_CMD_RXDISABLE、NULL);

uint8_t modbusFrame[]={0x01、0x03、0x00、0x01、0x00、 0x01、0xC4、0x39};
uint8_t modbusResponse [25];//根据预期的响应大小调整大小

//发送 Modbus 帧
UART_WRITE (UART、modbusFrame、sizeof (modbusFrame));

//等待短暂的延迟以接收响应
睡眠(2);

//读取 Modbus 响应
display_printf (display、0、0、"Before UART_readPolling\n");
int length = UART_readPolling (UART、modbusResponse、sizeof (modbusResponse));
display_printf (display、0、0、"After UART_readPolling\n");


控制台日志

启动 RTC 任务

向 DS3231写入时间时出错

RTC 设置时间失败

启动 UART MODBUS 任务

在 UART_readPolling 之前



SysConfig 引脚多路复用器


还有助于启用 UART 调试选项?