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.

CC1310 UARTecho问题

在正确运行了uartecho例程基础上,为了进一步了解串口的配置参数,对例程中的参数进行修改测试

遇见了几个问题:

1.例程的思路是echo,为什么还要把 uartParams.readEcho = UART_ECHO_OFF?

2. 在读返回模式中

* @brief UART return mode settings
*
* This enumeration defines the return modes for UART_read() and
* UART_readPolling(). This mode only functions when in UART_DATA_TEXT mode.

uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;

为什么例程在二进制模式下依然有效?

3.

uartParams.writeDataMode = UART_DATA_TEXT;
uartParams.readDataMode = UART_DATA_TEXT;
uartParams.readReturnMode = UART_RETURN_NEWLINE;
uartParams.readEcho = UART_ECHO_ON;

在这个参数组合下,为什么还能响应非换行符的数据?

  • 可以参考下面文档了解UART中各个参数的作用

    例如:

    Modes of Operation

    The UART driver can operate in blocking mode or callback mode, by setting the writeMode and readMode parameters passed to UART_open(). If these parameters are not set, as in the example code, the UART driver defaults to blocking mode. Options for the writeMode and readMode parameters are UART_MODE_BLOCKING and UART_MODE_CALLBACK:

    • UART_MODE_BLOCKING uses a semaphore to block while data is being sent. The context of calling UART_read() or UART_write() must be a Task when using UART_MODE_BLOCKING. The UART_write() or UART_read() call will block until all data is sent or received, or the write timeout or read timeout expires, whichever happens first.
    • UART_MODE_CALLBACK is non-blocking and UART_read() and UART_write() will return while data is being sent in the context of a hardware interrupt. When the read or write finishes, the UART driver will call the user's callback function. In some cases, the UART data transfer may have been canceled, or a newline may have been received, so the number of bytes sent/received are passed to the callback function. Your implementation of the callback function can use this information as needed. Since the user's callback may be called in the context of an ISR, the callback function must not make any RTOS blocking calls. The buffer passed to UART_write() in UART_MODE_CALLBACK is not copied. The buffer must remain coherent until all the characters have been sent (ie until the tx callback has been called with a byte count equal to that passed to UART_write()).

    The example sets the writeDataMode and readDataMode parameters to UART_DATA_BINARY. Options for these parameters are UART_DATA_BINARY and UART_DATA_TEXT:

    • UART_DATA_BINARY: The data is passed as is, without processing.
    • UART_DATA_TEXT: Write actions add a carriage return before a newline character, and read actions replace a return with a newline. This effectively treats all device line endings as LF and all host PC line endings as CRLF.

    Other parameters set by the example are readReturnMode and readEcho. Options for the readReturnMode parameter are UART_RETURN_FULL and UART_RETURN_NEWLINE:

    • UART_RETURN_FULL: The read action unblocks or returns when the buffer is full.
    • UART_RETURN_NEWLINE: The read action unblocks or returns when a newline character is read, before the buffer is full.

    Options for the readEcho parameter are UART_ECHO_OFF and UART_ECHO_ON. This parameter determines whether the driver echoes data back to the UART. When echo is turned on, each character that is read by the target is written back, independent of any write operations. If data is received in the middle of a write and echo is turned on, the echoed characters will be mixed in with the write data.