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.

RTOS/TMDSLCDK6748: Uart callback mode reads the data only one time.

Part Number: TMDSLCDK6748
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello,

I am using SYSBIOS 6.73.1.01 and  XDC 3.50.8.24. I am trying to use the UART_BasicExample_lcdkOMAPL138_c674xExampleProject in the UART callback mode so it does not block the process but it is not updating the value received via UART. The buffer only contains the very first received value and does not update any further. 

Here is my code:

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

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

#include "stdio.h"
#include "stdint.h"
#include "stdlib.h"
#include "string.h"

/* CSL Header files */
#ifdef _TMS320C6X
#include <ti/csl/csl_chip.h>
#endif

/* UART Header files */
#include <ti/drv/uart/UART.h>
#include <ti/drv/uart/UART_stdio.h>

#include <ti/drv/uart/test/src/UART_board.h>
#include <ti/drv/uart/src/v0/UART_v0.h>
#include <ti/drv/uart/soc/UART_soc.h>
/*
* ======== echoFxn ========
* Task for this function is created statically. See the project's .cfg file.
*
*/

/* Length of the input in number of characters */
#define INPUT_LENGTH (16U)

char echoPrompt[]="\nuart driver and utils example test cases :\nEnter 150 characters or press the esc \n";
char echoPrompt1[15] = {0};

UART_Callback callback;
size_t readsize = 15;
UART_HwAttrs uart_cfg;
UART_Params params;
UART_Handle myuart2;
int uartcheck;
uint32_t baud = 9600;
extern void UART_init(void);
void Board_initUART(void)
{
Board_initCfg boardCfg;


boardCfg = BOARD_INIT_PINMUX_CONFIG |
BOARD_INIT_MODULE_CLOCK |
BOARD_INIT_UART_STDIO;
Board_init(boardCfg);
}


Void uart_test(UArg arg0, UArg arg1)
{
char input = '\n';
char *buffPointer;


buffPointer = (char*)malloc(INPUT_LENGTH);
memset(buffPointer,0,INPUT_LENGTH);


while(1)
{
(*callback)(myuart2,echoPrompt1,readsize);

}
} /* uart_test */


/*
* ======== main ========
*/
int main(void)
{
/* Call board init functions */
Task_Handle task;
Error_Block eb;

// Board_initUART();
UART_init();
UART_socGetInitCfg(1U, &uart_cfg);
UART_socSetInitCfg(1U, &uart_cfg);

callback = &UART_read;

UART_Params_init(&params);
params.baudRate = baud;
params.readMode = UART_MODE_CALLBACK;
params.writeMode = UART_MODE_CALLBACK;
params.readCallback = callback;
params.readReturnMode = UART_RETURN_NEWLINE;
// params.readReturnMode = UART_RETURN_FULL;
myuart2 = UART_open(1U , &params);

Error_init(&eb);
task = Task_create(uart_test, NULL, &eb);
if (task == NULL) {
System_printf("Task_create() failed!\n");
BIOS_exit(0);
}

/* Start BIOS */
BIOS_start();
return (0);
} /* main */

  • Hello Prashant,

    There is a UART callback mode example in UART_BasicExample_lcdkOMAPL138_c674xTestProject. Can you use that?

    I went ahead and stripped out all the other tests in the example besides the callback mode test and attached it below for your reference. 

    /cfs-file/__key/communityserver-discussions-components-files/791/main_5F00_uart_5F00_test.c

    I verified it's working on my LCDK as well. 

  • Hello Sahin,

    Thank you so much for your quick response.

    Yes,I am able to compile and run the code you have provided. However i am not able to find the buffer in which the data is stored, I verified addrScanPrompt and scanPrompt buffers but did not find anything.

    Anyways, my goal is to read the data from a laser which throws a string at a specific frequency in the callback(non-blocking) mode. I have attached the screenshot of the data string I have to receive.  I am able to receive the data in blocking mode successfully but not in the callback mode. I have found the information regarding the initialization of the peripheral on the below link and treid to tweak it for callback mode.

    http://software-dl.ti.com/processor-sdk-rtos/esd/docs/latest/rtos/index_device_drv.html#uart

     

    Even though you have provided the test code for the Uart callback mode (Non-DMA), I could not fully understand the code because of the function used in it and was not able to find any user guide or any other document to understand it. can you help me with it?

    and also where can i find the documentation to read a string via uart in callback mode(Non-DMA).

    Your help is very much appreciated.

  • Hello prashant,

    Can you check the UART interrupt register after the first value is received and the application has hanged? Specifically, these registers:

    Regarding the test example, the data gets stored in transaction.buf before each transaction:

    /* Read in call back mode */
        memset(scanPrompt, 0, sizeof(scanPrompt));
        if (dmaMode)
        {
            CacheP_wbInv((void *)(uintptr_t)addrScanPrompt, (int32_t)sizeof(scanPrompt));
        }
    
        UART_transactionInit(&callbackTransaction);
        callbackTransaction.buf = (void *)(uintptr_t)addrScanPrompt;
        callbackTransaction.count = xferSize;
        if (UART_read2(uart, &callbackTransaction) == UART_ERROR)
        {
            goto Err;
        }
    
        /* Write in blocking mode */
        UART_transactionInit(&transaction);
        transaction.buf = (void *)(uintptr_t)addrFifoTrgLvlData;
        transaction.count = xferSize;
        if (UART_write2(uart, &transaction) == UART_ERROR)
        {
            goto Err;
        }