Other Parts Discussed in Thread: CC1350,
I need to receive a data stream over UART in callback mode and I need to store the stream in buffer entities of 26 bytes. Thus I have used partial return mode. It usually works for messages below 128 bytes, but above it does not work in most of the cases. Sometimes I can receive up to 192 bytes, sometimes I even got 256, but most of the time, I can only receive 128 bytes.
I have created a minimal test application.
- Import the uartEcho example from SDK 4.10.01 (you can use TIRTOS, NoRTOS, it doesn't matter)
- Replace the attached uartecho.c file
- Configure the serial port to 38400 (or change the baudrate in the example accordingly, the baudrate doesn't really matter)
- Send a long message from a terminal in one go, for instance 300 bytes long. It is important to send it as a single message. As soon as there is a pause in between, the mcu receives more bytes.
- Halt the application after sending the message and check the bytesReceived variable.
Could you help me to find out what causes the problem?
Thanks
/* * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * ======== uartecho.c ======== */ #include <stdint.h> #include <stddef.h> /* Driver Header files */ #include <ti/drivers/GPIO.h> #include <ti/drivers/UART.h> #include <ti/drivers/uart/UARTCC26XX.h> /* Example/Board Header files */ #include "Board.h" uint8_t data[1024]; uint32_t bytesReceived; void uartReadCallback(UART_Handle handle, void *buffer, size_t num) { bytesReceived += num; UART_read(handle, &data, 26); } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { char input; const char echoPrompt[] = "Echoing characters:\r\n"; UART_Handle uart; UART_Params uartParams; /* Call driver init functions */ GPIO_init(); UART_init(); /* Configure the LED pin */ GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); /* Turn on user LED */ GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON); UART_Params_init(&uartParams); uartParams.baudRate = 38400; uartParams.readDataMode = UART_DATA_BINARY; uartParams.readMode = UART_MODE_CALLBACK; uartParams.readCallback = &uartReadCallback; uartParams.readEcho = UART_ECHO_OFF; uartParams.readReturnMode = UART_RETURN_FULL; uart = UART_open(Board_UART0, &uartParams); UART_control(uart, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL); UART_read(uart, &data, 26); if (uart == NULL) { /* UART_open() failed */ while (1); } while (1) { usleep(10000); } }