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.

C6747 UART DMA Issues



Hi,

I am using C6747 starter kit with DSP BIOS 5.33.05.  I was told by previous reply to download PSP 1.30.01 and I did that.  I tooked the uartSample project file straight from C:\Program Files\Texas Instruments\pspdrivers_01_30_01\packages\ti\pspiom\examples\evm6747\uart\edma.  I include the modiled sample at below and I will list which features worked in this sample code and what didn't.  I will need your inputs on the problem items.

The modified sample code only do 2 things.  First, it transmits a tring of ASCII string.  Last, it wait for 10 incoing bytes.  What worked was if the PC transmited 10 or more bytes.  I had a breakpoint at CallBackFunction() function and the Uart_TxBuffer first 10 bytes has the first 10 bytes of PC transmitted data.

Here are my issues:

1. When the PC sends 5 bytes (less than 10), according to RandyP previous reply the gioAttrs.timeout = 1000 should trigger my callback function CallBackFunction().  CallBackFunction() never got called.  Why the timeout does not work? Does it work for the synchronous/blocking mode only? My assumption gioAttrs.timeout is in msec.

2. When the PC sends 15 bytes.  Seems that I can not call another GIO_submit(hUart_IN,IOM_READ,buf,&len, &RxCallbackFunction) inside of CallbackFunction() function.

3. I made a change in the Rx buffer len of 1 to retreive any Rx length but I could not get the re-entry work similar to item 2.  Please let me know how the application should set up to get a call back continuously during run-time.  I hope that the application do not have to call GIO_submit(hUart_IN,IOM_READ,...) constantly.

4. This is a very simple subject from other microcontrollers (Freescale, STMico, etc.).  However, the uartSample code is not clear.  From C674x UART SPRUFM6B.PDF, section 2.9 DMA Event Support, there are URXEVT at the UART driver level.

Receive event (URXEVT): The trigger level for the receiver FIFO (1, 4, 8, or 14 characters) is set with
the RXFIFTL bit in the FIFO control register (FCR). Every time the trigger level is reached or a receiver
time-out occurs
, the UART sends a receive event to the EDMA controller. In response, the EDMA
controller reads the data from the receiver FIFO by way of the receiver buffer register (RBR). Note that
the receive event is not asserted if the data at the top of the receiver FIFO is erroneous even if the
trigger level has been reached.

How do I set this receiver timeout from the application level?

Thanks

>>>>>>>>>>>> Modified Sample Code <<<<<<<<<<<<<<<<

extern EDMA3_DRV_Handle hEdma; /* EDMA handle (Required in EDMA mode) */
extern EDMA3_DRV_Result edma3init();

Uart_Params   uartParams;

#pragma DATA_ALIGN(uartTestStringStart, 128);
static Int8 uartTestStringStart[128];

#pragma DATA_ALIGN(Uart_TxBuffer, 128);
static Int8  Uart_TxBuffer[1024];

GIO_Handle hUart_IN;

GIO_Handle hUart_OUT;

void uart0_dev_init(void);

static void genericUartTest();

GIO_AppCallback RxCallbackFunction;
GIO_AppCallback TxCallbackFunction;

Void main(Void)
{
    return;
}

Void echo(Void)
{
    GIO_Attrs       txGioAttrs      = GIO_ATTRS;
    GIO_Attrs       gioAttrs      = GIO_ATTRS;
    Int32           echoTskStatus = 0;
    Uart_ChanParams chanParams    = {NULL};

    /* Initialize channel attributes.                                         */
    txGioAttrs.nPackets = 2;

    gioAttrs.nPackets = 2;
 gioAttrs.timeout = 1000;

    chanParams.hEdma = hEdma;

    /* Initialize pinmux and evm related configurations                       */
    configureUart();

   /* Initialize UART Currently is been used to display a string              */
    hUart_OUT = GIO_create("/UART0",IOM_OUTPUT,NULL,&chanParams,&txGioAttrs);
    hUart_IN  = GIO_create("/UART0",IOM_INPUT,&echoTskStatus,&chanParams,&gioAttrs);

    if ((NULL == hUart_IN) || (NULL == hUart_OUT))
    {
        LOG_printf(&trace, "ERROR: Initialization of UART failed\n");
        return;
    }

    if ((NULL != hUart_IN) && (NULL != hUart_OUT))
    {
        /* Run UART sample application */
        genericUartTest();

  for (;;) { TSK_sleep(10); }

        /* Exit                                                               */
        SYS_exit(0);
    }
    return;
}

void user_uart0_init()
{
    EDMA3_DRV_Result    edmaResult      = 0;

    if (NULL == hEdma)
    {
        edmaResult = edma3init();

        if (edmaResult != EDMA3_DRV_SOK)
        {
            /* Report EDMA Error */
            LOG_printf(&trace,"\r\nEDMA3 : edma3init() failed\r\n");
        }
        else
        {
            LOG_printf(&trace,"\r\nEDMA3 : edma3init() passed\r\n");
        }
    }

    Uart_init();
    uartParams = Uart_PARAMS;
    uartParams.hwiNumber = 9;
    uartParams.opMode = Uart_OpMode_DMAINTERRUPT;
    uartParams.rxThreshold = Uart_RxTrigLvl_1;
    uartParams.softTxFifoThreshold = 1;
 uartParams.baudRate = Uart_BaudRate_115_2K;
}

void CallBackFunction( void )
{
    printf("CallBackFunction -\n");
}

static Void genericUartTest(Void)
{
    Ptr     buf    = NULL;
    Int     status = 0;
    size_t  len    = 0;
    Int8  *str = "UART Demo Starts INPUT a file of size 1000 bytes\r\n";

    printf("Starting UART sample application...\n");

    memset(Uart_TxBuffer, 0, 1024);

    /* Copy to start string to Cache aligned buffer                           */
    len = strlen(str);
    memcpy(uartTestStringStart,str,len);

    buf = uartTestStringStart;
    status = GIO_submit(hUart_OUT,IOM_WRITE, buf, &len, NULL);

    if(!((status == IOM_COMPLETED)||(status == IOM_PENDING)))
    {
        printf("\n Error from GIO_write for UART Test string\n");
    }
 else
 {
        printf("Setup Tx callback successfully...\n");
 }

    buf = Uart_TxBuffer;
    len = 10;
   RxCallbackFunction.fxn = (GIO_TappCallback)CallBackFunction;
   RxCallbackFunction.arg = NULL;
    status = GIO_submit(hUart_IN,IOM_READ,buf,&len, &RxCallbackFunction);

    if (!((status == IOM_COMPLETED)||(status == IOM_PENDING)))
    {
        printf("\n Error from GIO_read for 10 bytes read\n");
    }
 else
 {
        printf("Setup Rx callback successfully...\n");
 }

    printf("UART sample application completed\n");
}