微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > CC2640串口驱动异常

CC2640串口驱动异常

时间:10-02 整理:3721RD 点击:

Hi,All,

SDK版本:ble_cc26xx_2_01_01_44627;

在使用阻塞模式下,仅在单Task下操作串口,基本模式都是先写,然后在一定时间内读串口内容,在操作一段时间后,出现readsize非零,导致read返回-1。

断点看出来objcect的内容是正常的,基本可以排除内存操作异常导致。出问题的驱动read函数部分如下:

int UARTCC26XX_read(UART_Handle handle, void *buffer, size_t size)
{
unsigned int key;
UARTCC26XX_Object *object;
UARTCC26XX_HWAttrs const *hwAttrs;

/* Get the pointer to the object */
object = handle->object;
hwAttrs = handle->hwAttrs;

/* Disable preemption while checking if the uart is in use. */
key = Hwi_disable();

//////////////////////////////////// 出问题时,这里返回 /////////////////////////////////////////////////////////

if (object->readSize) {
Hwi_restore(key);

Log_warning1("UART:(%p) Could not read data, uart in use.",
((UARTCC26XX_HWAttrs const *)(handle->hwAttrs))->baseAddr);

return (UART_ERROR);
}

.............

有遇到类似问题的么?

阻塞模式是啥?cc2640串口接收的数据每秒有多少字节。

Hi, 大秦正声,

阻塞模式,就是设置读写都为UART_MODE_BLOCKING,就是读写都等待完成或超时后函数调用才会返回;速率是115200;

官方驱动配置结构:

/*!
* @brief UART Parameters
*
* UART parameters are used to with the UART_open() call. Default values for
* these parameters are set using UART_Params_init().
*
* @sa UART_Params_init()
*/
typedef struct UART_Params {
UART_Mode readMode; /*!< Mode for all read calls */
UART_Mode writeMode; /*!< Mode for all write calls */
unsigned int readTimeout; /*!< Timeout for read semaphore */
unsigned int writeTimeout; /*!< Timeout for write semaphore */
UART_Callback readCallback; /*!< Pointer to read callback */
UART_Callback writeCallback; /*!< Pointer to write callback */
UART_ReturnMode readReturnMode; /*!< Receive return mode */
UART_DataMode readDataMode; /*!< Type of data being read */
UART_DataMode writeDataMode; /*!< Type of data being written */
UART_Echo readEcho; /*!< Echo received data back */
uint32_t baudRate; /*!< Baud rate for UART */
UART_LEN dataLength; /*!< Data length for UART */
UART_STOP stopBits; /*!< Stop bits for UART */
UART_PAR parityType; /*!< Parity bit type for UART */
void *custom; /*!< Custom argument used by driver
implementation */
} UART_Params;

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top