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.

TI-RTOS How to change the serial polling mode to interrupt mode

Other Parts Discussed in Thread: SYSBIOS

Hi  all

MCU: TM4C1294NCPDT

TI-RTOS: v2.01.00.36

NDK: v2.23.01.01

CCS: v6.0.1.0040

SYS/BIOS    6.4..02.27  GA  Release  Note

      How to change the uart polling mode to interrupt  mode ?

/*
* ======== uartecho.c ========
*/

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>

/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>

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

#include <stdint.h>
#include "inc/hw_memmap.h"

/*
* ======== echoFxn ========
* Task for this function is created statically. See the project's .cfg file.
*/
Void echoFxn(UArg arg0, UArg arg1)
{
char input;
UART_Handle uart;
UART_Params uartParams;
const char echoPrompt[] = "\fEchoing characters:\r\n";

/* 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 = 9600;
uart = UART_open(Board_UART0, &uartParams);

if (uart == NULL) {
System_abort("Error opening the UART");
}

UART_write(uart, echoPrompt, sizeof(echoPrompt));

/* Loop forever echoing */
while(1){
UART_read(uart, &input, 1);
UART_write(uart, &input, 1);
}
}

/*
* ======== main ========
*/
int main(void)
{
/* Call board init functions */
Board_initGeneral();
Board_initGPIO();
Board_initUART();

/* Turn on user LED */
GPIO_write(Board_LED0, Board_LED_ON);

/* This example has logging and many other debug capabilities enabled */
System_printf("This example does not attempt to minimize code or data "
"footprint\n");
System_flush();

System_printf("Starting the UART Echo example\nSystem provider is set to "
"SysMin. Halt the target to view any SysMin contents in "
"ROV.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();

/* Start BIOS */
BIOS_start();

return (0);
}

Should I how to modify it?

I look forward to your reply!

Regards

Lewis

  • Hi Lewis,

    UART_read() and UART_write() are interrupt based. UART_writePolling() and UART_readPolling() are polling.

    When using the interrupt based method, you can either use UART_MODE_BLOCKING or UART_MODE_CALLBACK (used when you create the UART). UART_MODE_BLOCKING means the UART_read/UART_write calls will be blocking. UART_MODE_CALLBACK means the UART_read/UART_write calls are non-blocking. Instead the user supplied callback is called upon completion of the read or write.

    Todd

     

  • Hi Todd
    About UARTCharsAvail(UART3_BASE), why in the serial task function inside it can not be used?
    The UART3_BASE replaced by any non-zero value, the result will be the return value of this function is always true.
    RegardsLewis
  • Lewis,

    I don't understand what you are asking. Is this a new question? If it is, please start a new thread. If not, can you restate your question.

    Todd