Part Number:CC2642R-Q1Other Parts Discussed in Thread:CC2340R5
TI 工程师,你们好!
我们目前有两个的项目,一个用CC2642R1F,一个用CC2340R5,都是做LIN从机,发现一个相同的问题:就是接收中断耗时太长。
从LIN总线看数据,数据接收完成到程序运行到中断回调函数,用时1.8ms,这直接导致我们的从机响应超时,用CAN OE测试根本过不了。
我现在不确定是我们的串口配置问题(用的官方例程配的),还是TI芯片内部特性问题,故来请教。
UART2CC26X2_Object UserUart2CC26X2Objects[1];
#define DEFAULTlEN 32 //也可设置到255
static unsigned char UserUart2RxRingBuf[DEFAULTlEN];
/* TX ring buffer allocated to be used for nonblocking mode */
static unsigned char UserUart2TxRingBuf[DEFAULTlEN];
static const UART2CC26X2_HWAttrs UserUart2CC26X2HWAttrs[1] = {
{
.baseAddr = UART0_BASE, //uart0用于LIN通信
.intNum = INT_UART0_COMB,
.intPriority = (~0),
.rxPin = CONFIG_GPIO_USER_UART_RX,//IOID_24,
.txPin = CONFIG_GPIO_USER_UART_TX,//IOID_23,/IOID_25
.ctsPin = GPIO_INVALID_INDEX,
.rtsPin = GPIO_INVALID_INDEX,
.flowControl = UART2_FLOWCTRL_NONE,
.powerId = PowerCC26XX_PERIPH_UART0,
.rxBufPtr = UserUart2RxRingBuf,
.rxBufSize = sizeof(UserUart2RxRingBuf),
.txBufPtr = UserUart2TxRingBuf,
.txBufSize = sizeof(UserUart2TxRingBuf),
.txPinMux = IOC_PORT_MCU_UART0_TX,
.rxPinMux = IOC_PORT_MCU_UART0_RX,
.txIntFifoThr = UART2CC26X2_FIFO_THRESHOLD_1_8,
.rxIntFifoThr = UART2CC26X2_FIFO_THRESHOLD_4_8
}
};
const UART2_Config UserUart2_config[1] = {
{ /* CONFIG_USER_UART */
.object = &UserUart2CC26X2Objects[CONFIG_USER_UART],
.hwAttrs = &UserUart2CC26X2HWAttrs[CONFIG_USER_UART]
},
};
void user_uart_init(void)
{
UART2_Params LinUartParams;
// Specify non-default parameters
UART2_Params_init(&LinUartParams);
LinUartParams.baudRate = 19200;
LinUartParams.readMode = UART2_Mode_CALLBACK;
LinUartParams.readCallback = UserUartRdCallback;
// Open the UART and initiate the first read
LinUartHandle = UART2_open(CONFIG_USER_UART, &LinUartParams);
if(LinUartHandle == NULL)
{
Printf("user uart UART2_open() failed\n");
while(1);
} else {
Printf("user uart init success\n");
}
UART2_read(LinUartHandle,UartLinRxBuf,sizeof(UartLinRxBuf),NULL);
}
static void UserUartRdCallback(UART2_Handle handle, void *RxBuf, size_t count,void *userArg, int_fast16_t status) //串口接收回调函数
{
if(status!=UART2_STATUS_SUCCESS) {
Printf("RX error occured in UART2_read()\n");
while (1) {}
} if(count>0) {
memcpy(UartLinRxBuf,RxBuf,count);
} UartRxByteCnt=count; GPIO_resetConfig(TESTIO);//////////////////////////在接收回调里置低测试IO口(抓图为蓝线)
Event_post(SlaverTskEvtHandle,SLAVER_UART_LINRX_EVT);
}
Janet:
TI工程师在吗?能否麻烦跟踪/回答一下我的问题呢?
这个1.8ms要减少到410us才能满足lin协议。
谢谢