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.
大家好:
SDK版本: simplelink_cc13x2_26x2_sdk_4_40_00_44
例程:zed_sw_ota_client
MCU:CC1352P-2 LP 开发环境:CCS10
请教大家一个问题
我在使用UART2_Callback模式处理串口接收时遇到一个问题,当串口发数据较长时,进入我callback中Set的event会不稳定,有时进一次,有时进两次。
付代码如下:
说明:在zclSampleSw_Init()中调用 hl_uart_open();初始化Uart2,当有串口数据接收到时,会进入我写的loop(在zclSampleSw_process_loop 主loop中)
在里边打印字符串“uart”。图三为我UART2配置,RX TX Ring Buffer 都为32
现象:当我发送数据较长时 31个字节(如下图2),发现会不稳定,有时进一次我的loop 有时进2次,图一是4字节,只会进一次loop
问题:请问是不是这个buffer满了?这个32是单位为字节吗?callback模式下如何处理接收较长的数据?
感谢!!!
uint8_t ch_uart; // write a string void hl_print_string(char *buffer) { char symbol[2] = "\r\n"; UART2_write(UartHandle,buffer,strlen(buffer),NULL); UART2_write(UartHandle,symbol,2,NULL); } //open && init void hl_uart_open(void) { UART2_Params_init(&UartParams); UartParams.baudRate = 115200; UartParams.readMode = UART2_Mode_CALLBACK; UartParams.readCallback = AtProcess_processingLoop; UartHandle = UART2_open(CONFIG_UART2_0, &UartParams); if(UartHandle == NULL) { hl_print_string("Error opening the UART"); } else { hl_print_string("UART open success"); status = UART2_read(UartHandle, &ch_uart, 1,NULL); } } //read callback void AtProcess_processingLoop(UART2_Handle _handle, void *_buf, size_t _size, void *userArg, int_fast16_t status) { if (status != UART2_STATUS_SUCCESS) { hl_print_string("Error"); } UART2_read(UartHandle, &ch_uart, 1,NULL); hlAppLoopEvents |= HL_ZED_UART_EVT; Semaphore_post(appSemHandle); } //my loop in zcl_samplesw.c void hlApp_event_loop(void) { if(hlAppLoopEvents & HL_ZED_1_EVT) { hlAppLoopEvents &= (~HL_ZED_HEART_EVT); } if(hlAppLoopEvents & HL_ZED_UART_EVT) { hl_print_string("uart"); hlAppLoopEvents &= (~HL_ZED_UART_EVT); } }
对于该参数的解释如下:
The RX ring buffer serves as an extension of the RX FIFO. If data is received when UART2_read() is not called, data will be stored in the RX ring buffer. The size can be changed to suit the application.
硬件UART FIFO深度的话只有32个字节。参考技术手册的 21.4.5 FIFO Operation 这是在硅中设置的,无法更改。FIFO中断级别可在各种FIFO填充深度处进行配置,如