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.

LAUNCHXL-CC2640R2: UART Callback does not work?

Part Number: LAUNCHXL-CC2640R2

I'm trying the uartecho_CC2640R2_LAUNCHXL_tirtos_css. But I changed uartecho.c to get readcallback.

If I send 1 by 1 byte, sometimes I lost connection. I dont know if I have something wrong in my callback or if I have to declare the writecallback in order to synchronize.

The same thing occurs when I declare a greater size in my buffer.

19:20:04: a
a <--response
19:20:04: a <--no more responses
19:20:06: dsa<--no more responses
19:20:07:
19:20:09:

The same response is when i send 8 bytes, I lost connection

19:22:26: 12345678
12345678<--response
19:22:28: 12345678
1<--response

/*

* ======== uartecho.c ========
*/
#include <stdint.h>
#include <stddef.h>

/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>

/* Example/Board Header files */
#include "Board.h"


static void readCallback(UART_Handle uart, void *buf, size_t count)
{


UART_write(uart, buf, count);
UART_read(uart, buf, count);
GPIO_toggle(Board_GPIO_LED0);

}

/*
* ======== 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();


/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.readCallback = readCallback;
uartParams.baudRate = 115200;

uart = UART_open(Board_UART0, &uartParams);
// UART_write(uart, echoPrompt, sizeof(echoPrompt));
int rx=UART_read(uart,&input, 1);
/* Loop forever echoing */
while (1) ;
}