TI中文支持网
TI专业的中文技术问题咨询交流网站

关于CC3220SF 的uartecho 例程我无法读取Rx 的数据?

1.我使用uartecho 驱动发送数据给传感器,传感器正常响应回发了数据,但是我uart_read 函数时程序阻塞在uart_read函数,我想知道uart_read函数的阻塞条件是什么原因造成的?

Kevin Qiu1:

/*!*@briefFunction that reads data from a UART with interrupt enabled.**%UART_read() reads data from a UART controller. The destination is specified*by \a buffer and the number of bytes to read is given by \a size.**In #UART_MODE_BLOCKING, %UART_read() blocks task execution until all*the data in buffer has been read.**In #UART_MODE_CALLBACK, %UART_read() does not block task execution.*Instead, a callback function specified by UART_Params::readCallback*is called when the transfer is finished.*The callback function can occur in the caller's context or in HWI or SWI*context, depending on the device-specific implementation.*An unfinished asynchronous read operation must always be canceled using*UART_readCancel() before calling UART_close().**%UART_read() is mutually exclusive to UART_readPolling(). For an opened*UART peripheral, either %UART_read() or UART_readPolling() can be used,*but not both.**@sa UART_readPolling()**@paramhandleA #UART_Handle returned by UART_open()**@parambufferA pointer to an empty buffer to which*received data should be written**@paramsizeThe number of bytes to be written into buffer**@return Returns the number of bytes that have been read from the UART,*#UART_STATUS_ERROR on an error.*/
extern int_fast32_t UART_read(UART_Handle handle, void *buffer, size_t size);

Lease:

回复 Kevin Qiu1:

我发现uart_read 函数是否是读取uart Rx线上的数据,uartecho例程调用uart_read函数等待键盘的输入,在发送给终端XDS110

Kevin Qiu1:

回复 Lease:

Leaseuartecho例程调用uart_read函数等待键盘的输入,在发送给终端XDS110

是的

Lease:

回复 Kevin Qiu1:

我传感器回发的的数据是二进制数,并没有换行符和新行,所以uart一直是阻塞的,那如何设置UART接收二进制数在不遇到、换行符就返回呢?

Kevin Qiu1:

回复 Lease:

使用UART_DATA_BINARY,数据按原样传递,不进行任何处理。
使用UART_DATA_TEXT才需要换行符

赞(0)
未经允许不得转载:TI中文支持网 » 关于CC3220SF 的uartecho 例程我无法读取Rx 的数据?
分享到: 更多 (0)