Dear,
I was testing the CC26x2 launchpad with my niece and the following code:
/*
*
*/
/*
* ======== 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"
uint8_t n;
/*
* ======== 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);
/* 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.baudRate = 115200;
uint32_t timeoutUs = 3000000;
uartParams.readTimeout = timeoutUs / 10;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL) {
/* UART_open() failed */
while (1);
}
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
n = UART_read(uart, &input, 1);
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
/* Loop forever echoing */
while (1) {
UART_read(uart, &input, 1);
UART_write(uart, &input, 1);
}
}
It is very similar to one of your examples uartecho.c.
We can see if we leave the RXD jumper on the Launchpad closed, the code does work. We can observe a 3 seconds LED approximately.
If you open such jumper, the code does NOT work. The LED blinks few milliseconds.
Why is this? How can we obtain the same 3 seconds expected blocking behavior somehow with both cases?
Thanks.