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.

TMS320C6748: UART0 EDMA NOT WORKING

Part Number: TMS320C6748


Hello,ed

I got c6748 UART2 EDMA starterware program working. I modified program for UART0,but not working. I changed all UART2 to UART0, changed TBR_RBR buffer, but still program dont work. Program is given below. Please help me find mistake.

/**
 * \file  uartEcho.c
 *
 * \brief This is a sample application file which invokes some APIs
 *        from the EDMA3 device abstraction layer as well as UART
 *        device abstraction layer to perform configuration, and
 *        transfer of data between UART and CPU RAM by the
 *        use of EDMA3
 */

/*
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*    Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
*
*    Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the
*    distribution.
*
*    Neither the name of Texas Instruments Incorporated nor the names of
*    its contributors may be used to endorse or promote products derived
*    from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "psc.h"
#include "uart.h"
#include "edma.h"
#include "string.h"
#include "hw_types.h"
#include "uartStdio.h"
#include "lcdkC6748.h"
#include "interrupt.h"
#include "edma_event.h"
#include "soc_C6748.h"
#include "hw_psc_C6748.h"

/****************************************************************************/
/*                      INTERNAL MACRO DEFINITIONS                          */
/****************************************************************************/
#define UART_RBR_THR_REG           ((0x01C42000u) + (0u))

#define MAX_ACNT                   1
#define MAX_CCNT                   1

#define RX_BUFFER_SIZE             20

/* EDMA3 Event queue number. */
#define EVT_QUEUE_NUM              0

/****************************************************************************/
/*                      LOCAL FUNCTION PROTOTYPES                           */
/****************************************************************************/
static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
                             volatile char *buffer, unsigned int buffLength);

/* Callback Function Declaration*/
static void (*cb_Fxn[EDMA3_NUM_TCC]) (unsigned int tcc, unsigned int status);
static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
                            volatile char *buffer);
static void callback(unsigned int tccNum, unsigned int status);
static void ConfigureIntEDMA3(void);
static void Edma3ComplHandlerIsr(void);
static void Edma3CCErrHandlerIsr(void);
static void EDMA3Initialize(void);
static void SetupInt(void);

/****************************************************************************/
/*                      GLOBAL VARIABLES                                    */
/****************************************************************************/
volatile unsigned int flag = 0;

/****************************************************************************/
/*                   LOCAL FUNCTION DEFINITIONS                             */
/****************************************************************************/

/*
** Main function.
*/

int main(void)
{
    volatile char enter[] = "\r\nPlease Enter 20 bytes from keyboard\r\n";
    volatile char buffer[RX_BUFFER_SIZE];
    unsigned int buffLength = 0;

    /* Initialize EDMA3 Controller */
    EDMA3Initialize();

    /* Initialize UART */
   // UARTStdioInit();
    PSCModuleControl(SOC_PSC_0_REGS,9, 0, PSC_MDCTL_NEXT_ENABLE);
    UARTPinMuxSetup(0, FALSE);
    UARTEnable(SOC_UART_0_REGS);

         /* Configuring the UART parameters*/
         /* 8-bit work length, no parity, 1 stop bit. */
         /* The UART module input frequency shall be 150MHz.*/
         UARTConfigSetExpClk(SOC_UART_0_REGS,
                             SOC_UART_0_MODULE_FREQ,
                             BAUD_115200,
                             UART_WORDL_8BITS,
                             UART_OVER_SAMP_RATE_16);


         /* Enables FIFO mode for transmitter and receiver.*/
         UARTFIFOEnable(SOC_UART_0_REGS);

         /* Sets the receiver FIFO Trigger level.*/
         UARTFIFOLevelSet(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1);




    /* Request DMA Channel and TCC for UART Transmit*/
    EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                        EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
                        EVT_QUEUE_NUM);

    /* Registering Callback Function for TX*/
    cb_Fxn[EDMA3_CHA_UART0_TX] = &callback;

    /* Request DMA Channel and TCC for UART Receive */
    EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                        EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX,
                        EVT_QUEUE_NUM);

    /* Registering Callback Function for RX*/
    cb_Fxn[EDMA3_CHA_UART0_RX] = &callback;

    /* Used for bCnt */
    buffLength = strlen((const char *) enter);

    /* Transmit Data for Enter Message */
    UartTransmitData(EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
                     enter, buffLength);

    /* Enabling UART in DMA Mode*/
    UARTDMAEnable(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1 |  \
                                   UART_DMAMODE |          \
                                   UART_FIFO_MODE );

    /* Wait for control to return from call-back function */
    while(0 == flag);
    flag = 0;

    /* Receive Data for Input */
    UartReceiveData(EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX, buffer);


    /* Enabling UART in DMA Mode*/
    UARTDMAEnable(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1 | \
                                   UART_DMAMODE |         \
                                   UART_FIFO_MODE );

    /* Wait for return from callback */
    while(0 == flag);
    flag = 0;

    /* Transmit Data for Entered value */
    UartTransmitData(EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
                     buffer, RX_BUFFER_SIZE);

    /* Enabling UART in DMA Mode*/
    UARTDMAEnable(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1 |  \
                                   UART_DMAMODE |           \
                                   UART_FIFO_MODE );

    /* Wait for return from callback */
    while(0 == flag);
    flag = 0;

    /* Free EDMA3 Channels for TX and RX */
    EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                     EDMA3_CHA_UART0_TX, EDMA3_TRIG_MODE_EVENT,
                     EDMA3_CHA_UART0_TX, EVT_QUEUE_NUM);

    EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                     EDMA3_CHA_UART0_RX, EDMA3_TRIG_MODE_EVENT,
                     EDMA3_CHA_UART0_RX, EVT_QUEUE_NUM);

    while(1);

}

/*
** This function is used to set the PaRAM entries in EDMA3 for the Transmit Channel
** of UART. EDMA3 Enable Transfer is also called within this API.
*/

static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
                             volatile char *buffer, unsigned int buffLength)
{
    EDMA3CCPaRAMEntry paramSet;

    /* Fill the PaRAM Set with transfer specific information */
    paramSet.srcAddr = (unsigned int) buffer;
    paramSet.destAddr = UART_RBR_THR_REG;
    paramSet.aCnt = MAX_ACNT;
    paramSet.bCnt = (unsigned short) buffLength;
    paramSet.cCnt = MAX_CCNT;

    /* The src index should increment for every byte being transferred. */
    paramSet.srcBIdx = (short) 1u;

    /* The dst index should not be increment since it is a h/w register*/
    paramSet.destBIdx = (short) 0u;

    /* A sync Transfer Mode */
    paramSet.srcCIdx = (short) 0u;
    paramSet.destCIdx = (short) 0u;
    paramSet.linkAddr = (unsigned short)0xFFFFu;
    paramSet.bCntReload = (unsigned short)0u;
    paramSet.opt = 0x00000000u;
    paramSet.opt |= (EDMA3CC_OPT_DAM );
    paramSet.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
    paramSet.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);

    /* Now write the PaRAM Set */
    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);

    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
}

/*
** This function is used to set the PARAM SET of EDMA3 for the Receive Channel
** of UART. EDMA3 Enable Transfer is also called within this API.
*/

static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
                            volatile char *buffer)
{
    EDMA3CCPaRAMEntry paramSet;

    /* Fill the PaRAM Set with transfer specific information */
    paramSet.srcAddr = UART_RBR_THR_REG;
    paramSet.destAddr = (unsigned int) buffer;
    paramSet.aCnt = MAX_ACNT;
    paramSet.bCnt = RX_BUFFER_SIZE;
    paramSet.cCnt = MAX_CCNT;

    /* The src index should not be increment since it is a h/w register*/
    paramSet.srcBIdx = 0;
    /* The dest index should incremented for every byte */
    paramSet.destBIdx = 1;

    /* A sync Transfer Mode */
    paramSet.srcCIdx = 0;
    paramSet.destCIdx = 0;
    paramSet.linkAddr = (unsigned short)0xFFFFu;
    paramSet.bCntReload = 0;
    paramSet.opt = 0x00000000u;
    paramSet.opt |= ((EDMA3CC_OPT_SAM) << EDMA3CC_OPT_SAM_SHIFT);
    paramSet.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
    paramSet.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);

    /* Now write the PaRAM Set */
    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);

    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
}

/* Function used to Initialize EDMA3 */
static void EDMA3Initialize(void)
{
    /* Enabling the PSC for EDMA3CC_0.*/
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_CC0, PSC_POWERDOMAIN_ALWAYS_ON,
             PSC_MDCTL_NEXT_ENABLE);

    /* Enabling the PSC for EDMA3TC_0.*/
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_TC0, PSC_POWERDOMAIN_ALWAYS_ON,
             PSC_MDCTL_NEXT_ENABLE);

    /* Initialization of EDMA3 */
    EDMA3Init(SOC_EDMA30CC_0_REGS, EVT_QUEUE_NUM);

    /*
    ** Enable AINTC to handle interuppts. Also enable IRQ interuppt in
    ** ARM processor.
    */
    SetupInt();

    /* Register EDMA3 Interrupts */
    ConfigureIntEDMA3();
}

/* Function used to Setup ARM Interuppt Controller */
static void SetupInt(void)
{
#ifdef _TMS320C6X
    // Initialize the DSP Interrupt controller
    IntDSPINTCInit();

    // Enable DSP interrupts globally
    IntGlobalEnable();
#else
    /*Initialize the ARM Interrupt Controller(AINTC). */
    IntAINTCInit();

    /* Enable IRQ in CPSR.*/
    IntMasterIRQEnable();

    /* Enable the interrupts in GER of AINTC.*/
    IntGlobalEnable();

    /* Enable the interrupts in HIER of AINTC.*/
    IntIRQEnable();
#endif
}

/* EDMA3 Completion Handler */
static void edma3ComplHandler(unsigned int baseAdd, unsigned int regionNum)
{
    volatile unsigned int pendingIrqs;
    volatile unsigned int isIPR = 0;

    unsigned int indexl;
    unsigned int Cnt = 0;
    indexl = 1;

#ifdef _TMS320C6X
    IntEventClear(SYS_INT_EDMA3_0_CC0_INT1);
#else
    IntSystemStatusClear(SYS_INT_CCINT0);
#endif
    isIPR = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
    if(isIPR)
    {
        while ((Cnt < EDMA3CC_COMPL_HANDLER_RETRY_COUNT)&& (indexl != 0u))
        {
            indexl = 0u;
            pendingIrqs = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
            while (pendingIrqs)
            {
                if((pendingIrqs & 1u) == TRUE)
                {
                    /**
                    * If the user has not given any callback function
                    * while requesting the TCC, its TCC specific bit
                    * in the IPR register will NOT be cleared.
                    */
                    /* here write to ICR to clear the corresponding IPR bits */
                    HWREG(baseAdd + EDMA3CC_S_ICR(regionNum)) = (1u << indexl);

                    (*cb_Fxn[indexl])(indexl, EDMA3_XFER_COMPLETE);
                }
                ++indexl;
                pendingIrqs >>= 1u;
            }
            Cnt++;
        }
    }
}

static void Edma3ComplHandlerIsr(void)
{
#ifdef _TMS320C6X
    // Invoke Completion Handler ISR
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 1);
#else
    /* Invoke Completion Handler ISR */
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 0);
#endif
}

/* EDMA3 Error Handler */
static void edma3CCErrHandler(unsigned int baseAdd)
{
    volatile unsigned int pendingIrqs = 0;
    unsigned int regionNum = 0;
    unsigned int evtqueNum = 0;
    unsigned int index = 1;
    unsigned int Cnt = 0;

#ifdef _TMS320C6X
    IntEventClear(SYS_INT_EDMA3_0_CC0_ERRINT);
#else
    IntSystemStatusClear(SYS_INT_CCERRINT);
#endif

    if((HWREG(baseAdd + EDMA3CC_EMR) != 0 ) || \
       (HWREG(baseAdd + EDMA3CC_QEMR) != 0) || \
       (HWREG(baseAdd + EDMA3CC_CCERR) != 0))
    {
        /* Loop for EDMA3CC_ERR_HANDLER_RETRY_COUNT number of time, breaks
           when no pending interrupt is found */
        while ((Cnt < EDMA3CC_ERR_HANDLER_RETRY_COUNT) && (index != 0u))
        {
            index = 0u;
            pendingIrqs = HWREG(baseAdd + EDMA3CC_EMR);
            while (pendingIrqs)
            {
                /*Process all the pending interrupts*/
                if((pendingIrqs & 1u)==TRUE)
                {
                    /* Write to EMCR to clear the corresponding EMR bits.*/
                    HWREG(baseAdd + EDMA3CC_EMCR) = (1u<<index);
                    /*Clear any SER*/
                    HWREG(baseAdd + EDMA3CC_S_SECR(regionNum)) = (1u<<index);
                }
                ++index;
                pendingIrqs >>= 1u;
            }
            index = 0u;
            pendingIrqs = HWREG(baseAdd + EDMA3CC_QEMR);
            while (pendingIrqs)
            {
                /*Process all the pending interrupts*/
                if((pendingIrqs & 1u)==TRUE)
                {
                    /* Here write to QEMCR to clear the corresponding QEMR bits*/
                    HWREG(baseAdd + EDMA3CC_QEMCR) = (1u<<index);
                    /*Clear any QSER*/
                    HWREG(baseAdd + EDMA3CC_S_QSECR(0)) = (1u<<index);
                }
                ++index;
                pendingIrqs >>= 1u;
            }
            index = 0u;
            pendingIrqs = HWREG(baseAdd + EDMA3CC_CCERR);
    if (pendingIrqs != 0u)
    {
        /* Process all the pending CC error interrupts. */
        /* Queue threshold error for different event queues.*/
        for (evtqueNum = 0u; evtqueNum < EDMA3_0_NUM_EVTQUE; evtqueNum++)
        {
            if((pendingIrqs & (1u << evtqueNum)) != 0u)
            {
                /* Clear the error interrupt. */
                HWREG(baseAdd + EDMA3CC_CCERRCLR) = (1u << evtqueNum);
            }
         }

         /* Transfer completion code error. */
         if ((pendingIrqs & (1 << EDMA3CC_CCERR_TCCERR_SHIFT)) != 0u)
         {
             HWREG(baseAdd + EDMA3CC_CCERRCLR) = \
                  (0x01u << EDMA3CC_CCERR_TCCERR_SHIFT);
         }
         ++index;
    }
    Cnt++;
        }
    }
}

static void Edma3CCErrHandlerIsr()
{
    /* Invoke CC Error Handler ISR */
    edma3CCErrHandler(SOC_EDMA30CC_0_REGS);
}

/* Function to register EDMA3 Interuppts */
static void ConfigureIntEDMA3(void)
{
    /* Register Interrupts Here */

#ifdef _TMS320C6X
    IntRegister(C674X_MASK_INT4, Edma3ComplHandlerIsr);
    IntRegister(C674X_MASK_INT5, Edma3CCErrHandlerIsr);

    IntEventMap(C674X_MASK_INT4, SYS_INT_EDMA3_0_CC0_INT1);
    IntEventMap(C674X_MASK_INT5, SYS_INT_EDMA3_0_CC0_ERRINT);

    IntEnable(C674X_MASK_INT4);
    IntEnable(C674X_MASK_INT5);
#else
    IntRegister(SYS_INT_CCINT0, Edma3ComplHandlerIsr);

    IntChannelSet(SYS_INT_CCINT0, 2);

    IntSystemEnable(SYS_INT_CCINT0);

    IntRegister(SYS_INT_CCERRINT, Edma3CCErrHandlerIsr);

    IntChannelSet(SYS_INT_CCERRINT, 2);

    IntSystemEnable(SYS_INT_CCERRINT);
#endif
}


/*
** This function is used as a callback from EDMA3 Completion Handler.
** UART in DMA Mode is Disabled over here.
*/
static void callback(unsigned int tccNum, unsigned int status)
{
    UARTDMADisable(SOC_UART_0_REGS, (UART_RX_TRIG_LEVEL_1 | UART_FIFO_MODE));
    flag = 1;
}

/********************************* End of file ******************************/
 Thanks in advance

With RegardsShalini

  • The code looks okay. When you say "dont work", what does that mean? What platform are you using? On the LCDK, UART0 is shared with the network chip. By default, the UART0 pins on J15 are not connected due to unpopulated resistors. The network chip may need to be disabled or removed to avoid conflict with the UART lines.
  • Hello,

    I have populated the resistors. The pins are demultiplexed. The UART0 program works well in normal mode. When used in DMA mode the problem occurs. Please make suggestions to solve problem.

    With regards
    Shalini
  • Hello,

    When I look in the CCS debug window the receive buffer has none of the value received , the event completion do not occur for receive and the EMR register is set for event UART0 receive ie 9.

    With Regards
    Shalini
  • If it works in non-DMA mode, then the pins must be connected. I cannot find any obvious errors in you code. The events are enumerated in edma_event.h.
    #define EDMA3_CHA_UART0_RX 8
    #define EDMA3_CHA_UART0_TX 9
    How far does the program progress? Is the prompt printed?
    That's all I got. I can't think of anything at the moment.
  • The transmit pin transmits, I verified in CRO, but the receive completion does not occur. The program is staying at while(flag==0) after receive. The EDMA completion handler dont return.
  • Did you enter 20 characters? There is no character by character echo. You won't see feedback of your entry. You could try lowering RX_BUFFER_SIZE to 1 to enter just one character. Or entering some characters, stopping the program and examining the buffer to see if anything was DMA'ed over.
  • Sir,

    I am transmitting 1 to 8 continously from UART0 tx pin that is connected to UART0 rx pin using wires. Both tx and rx channel use DMA and EDMA3_0 Channel Controller 0 Shadow Region 1 Transfer Completion Interrupt. My receive buffer is viewed in CC studio, showing wrong values. But uART0 works well without DMA, when I connect tx and rx channels. Below is new program.


    /**
    * \file uartEcho.c
    *
    * \brief This is a sample application file which invokes some APIs
    * from the EDMA3 device abstraction layer as well as UART
    * device abstraction layer to perform configuration, and
    * transfer of data between UART and CPU RAM by the
    * use of EDMA3
    */

    /*
    * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the
    * distribution.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */

    #include "psc.h"
    #include "uart.h"
    #include "edma.h"
    #include "string.h"
    #include "hw_types.h"
    #include "uartStdio.h"
    #include "lcdkC6748.h"
    #include "interrupt.h"
    #include "edma_event.h"
    #include "soc_C6748.h"
    #include "hw_psc_C6748.h"

    /****************************************************************************/
    /* INTERNAL MACRO DEFINITIONS */
    /****************************************************************************/
    #define UART_RBR_THR_REG ((0x01C42000u) + (0u))

    #define MAX_ACNT 1
    #define MAX_CCNT 1

    #define RX_BUFFER_SIZE 20

    /* EDMA3 Event queue number. */
    #define EVT_QUEUE_NUM 16

    /****************************************************************************/
    /* LOCAL FUNCTION PROTOTYPES */
    /****************************************************************************/
    static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
    volatile char *buffer, unsigned int buffLength);

    /* Callback Function Declaration*/
    static void (*cb_Fxn[EDMA3_NUM_TCC]) (unsigned int tcc, unsigned int status);
    static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
    volatile char *buffer);
    static void callback(unsigned int tccNum, unsigned int status);
    static void ConfigureIntEDMA3(void);
    static void Edma3ComplHandlerIsr(void);
    static void Edma3ComplHandlerIsr1(void);
    static void Edma3CCErrHandlerIsr(void);
    static void EDMA3Initialize(void);
    static void SetupInt(void);

    /****************************************************************************/
    /* GLOBAL VARIABLES */
    /****************************************************************************/
    volatile unsigned int flag = 0;

    /****************************************************************************/
    /* LOCAL FUNCTION DEFINITIONS */
    /****************************************************************************/

    /*
    ** Main function.
    */

    int main(void)
    {
    //volatile char enter[] ={130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126};
    char buffer[RX_BUFFER_SIZE];
    unsigned int buffLength = 0;

    int cnt=0,cnt1=0,j1=0;
    char enter[7];
    for(cnt=0;cnt<7;cnt++)
    enter[cnt]=5;

    /* Initialize EDMA3 Controller */
    EDMA3Initialize();

    /* Initialize UART */
    // UARTStdioInit();
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_UART0, PSC_POWERDOMAIN_ALWAYS_ON,
    PSC_MDCTL_NEXT_ENABLE);
    UARTPinMuxSetup(0, FALSE);
    UARTEnable(SOC_UART_0_REGS);

    /* Configuring the UART parameters*/
    /* 8-bit work length, no parity, 1 stop bit. */
    /* The UART module input frequency shall be 150MHz.*/
    UARTConfigSetExpClk(SOC_UART_0_REGS,
    SOC_UART_0_MODULE_FREQ,
    BAUD_115200,
    UART_WORDL_8BITS,
    UART_OVER_SAMP_RATE_16);


    /* Enables FIFO mode for transmitter and receiver.*/
    UARTFIFOEnable(SOC_UART_0_REGS);

    /* Sets the receiver FIFO Trigger level.*/
    UARTFIFOLevelSet(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1);




    /* Request DMA Channel and TCC for UART Transmit*/
    EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
    EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
    EVT_QUEUE_NUM);

    /* Registering Callback Function for TX*/
    cb_Fxn[EDMA3_CHA_UART0_TX] = &callback;

    EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
    EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX,
    EVT_QUEUE_NUM);

    cb_Fxn[EDMA3_CHA_UART0_RX] = &callback;

    /* Used for bCnt */
    //buffLength = strlen((const char *) enter);
    buffLength=sizeof(enter);

    //while(1)
    //{
    /* Transmit Data for Enter Message */
    UartTransmitData(EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
    enter, buffLength);

    /* Enabling UART in DMA Mode*/

    UartReceiveData(EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX, buffer);


    UARTDMAEnable(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1 | \
    UART_DMAMODE | \
    UART_FIFO_MODE );

    /* Wait for control to return from call-back function */
    while(1);

    //}
    /* Receive Data for Input */

    EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
    EDMA3_CHA_UART0_TX, EDMA3_TRIG_MODE_EVENT,
    EDMA3_CHA_UART0_TX, EVT_QUEUE_NUM);

    EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
    EDMA3_CHA_UART0_RX, EDMA3_TRIG_MODE_EVENT,
    EDMA3_CHA_UART0_RX, EVT_QUEUE_NUM);




    }

    /*
    ** This function is used to set the PaRAM entries in EDMA3 for the Transmit Channel
    ** of UART. EDMA3 Enable Transfer is also called within this API.
    */
    int myflag1=0;
    static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
    volatile char *buffer, unsigned int buffLength)
    {
    EDMA3CCPaRAMEntry paramSet;
    EDMA3CCPaRAMEntry paramSet1;

    paramSet1.srcAddr = (unsigned int) buffer;
    paramSet1.destAddr = UART_RBR_THR_REG;
    paramSet1.aCnt = MAX_ACNT;
    paramSet1.bCnt = (unsigned short)buffLength;
    paramSet1.cCnt = MAX_CCNT;

    /* The src index should increment for every byte being transferred. */
    paramSet1.srcBIdx = (short) 2u;

    /* The dst index should not be increment since it is a h/w register*/
    paramSet1.destBIdx = (short) 0u;

    /* A sync Transfer Mode */
    paramSet1.srcCIdx = (short) 0u;
    paramSet1.destCIdx = (short) 0u;
    paramSet1.linkAddr = 0x01c043c0;
    paramSet1.bCntReload = (unsigned short)0u;
    paramSet1.opt = 0x00000000u;
    // paramSet1.opt |= (EDMA3CC_OPT_DAM );
    // paramSet1.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
    // paramSet1.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);
    paramSet1.opt |=0x00109002;

    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, 30, &paramSet1);

    /* Fill the PaRAM Set with transfer specific information */
    paramSet.srcAddr = (unsigned short)buffer;
    paramSet.destAddr = UART_RBR_THR_REG;
    paramSet.aCnt = MAX_ACNT;
    paramSet.bCnt = (unsigned short)buffLength;
    paramSet.cCnt = MAX_CCNT;

    /* The src index should increment for every byte being transferred. */
    paramSet.srcBIdx = (short) 2u;

    /* The dst index should not be increment since it is a h/w register*/
    paramSet.destBIdx = (short) 0u;

    /* A sync Transfer Mode */
    paramSet.srcCIdx = (short) 0u;
    paramSet.destCIdx = (short) 0u;
    paramSet.linkAddr = 0x01c043c0;
    paramSet.bCntReload = (unsigned short)0u;
    paramSet.opt = 0x00000000u;
    // paramSet.opt |= (EDMA3CC_OPT_DAM );
    // paramSet.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
    // paramSet.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);
    paramSet.opt |=0x00109002;
    myflag1=paramSet.opt;
    /* Now write the PaRAM Set */
    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);

    // 109002
    //409002
    //HWREG(SOC_EDMA30CC_0_REGS + 0x8c0) |=0x00000008;

    //HWREG(SOC_EDMA30CC_0_REGS + 0x8c0) |=0x00000100; //for DRAE1

    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
    }

    /*
    ** This function is used to set the PARAM SET of EDMA3 for the Receive Channel
    ** of UART. EDMA3 Enable Transfer is also called within this API.
    */

    int myflag=0;
    static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
    volatile char *buffer)
    {
    EDMA3CCPaRAMEntry paramSet;
    EDMA3CCPaRAMEntry paramSet1;

    /* Fill the PaRAM Set with transfer specific information */
    paramSet.srcAddr = UART_RBR_THR_REG;
    paramSet.destAddr = (unsigned int) buffer;
    paramSet.aCnt = MAX_ACNT;
    paramSet.bCnt = 16;
    paramSet.cCnt = MAX_CCNT;

    /* The src index should not be increment since it is a h/w register*/
    paramSet.srcBIdx =(short) 0u;
    /* The dest index should incremented for every byte */
    paramSet.destBIdx = (short) 1u;


    paramSet.srcCIdx = (short) 0u;
    paramSet.destCIdx = (short) 0u;
    paramSet.linkAddr =0x01c043e0;
    paramSet.bCntReload = (unsigned short)0u;
    paramSet.opt = 0x00000000u;
    paramSet.opt |=0x00108001;
    myflag=paramSet.opt;

    /* Now write the PaRAM Set */

    paramSet1.srcAddr = UART_RBR_THR_REG;
    paramSet1.destAddr = (unsigned int) buffer;
    paramSet1.aCnt = MAX_ACNT;
    paramSet1.bCnt = 16;
    paramSet1.cCnt = MAX_CCNT;

    /* The src index should not be increment since it is a h/w register*/
    paramSet1.srcBIdx =(short) 0u;
    /* The dest index should incremented for every byte */
    paramSet1.destBIdx = (short) 1u;


    paramSet1.srcCIdx = (short) 0u;
    paramSet1.destCIdx = (short) 0u;
    paramSet1.linkAddr = 0x01c043e0;
    paramSet1.bCntReload = (unsigned short)0u;
    paramSet1.opt = 0x00000000u;
    paramSet1.opt |=0x00108001;
    myflag=paramSet1.opt;

    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);
    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, 31, &paramSet1);

    // HWREG(SOC_EDMA30CC_0_REGS + 0x8c0) |=0x00000080; //for DRAE2
    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
    }

    /* Function used to Initialize EDMA3 */
    static void EDMA3Initialize(void)
    {
    /* Enabling the PSC for EDMA3CC_0.*/
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_CC0, PSC_POWERDOMAIN_ALWAYS_ON,
    PSC_MDCTL_NEXT_ENABLE);

    /* Enabling the PSC for EDMA3TC_0.*/
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_TC0, PSC_POWERDOMAIN_ALWAYS_ON,
    PSC_MDCTL_NEXT_ENABLE);

    /* Initialization of EDMA3 */
    EDMA3Init(SOC_EDMA30CC_0_REGS, EVT_QUEUE_NUM);

    /*
    ** Enable AINTC to handle interuppts. Also enable IRQ interuppt in
    ** ARM processor.
    */
    SetupInt();

    /* Register EDMA3 Interrupts */
    ConfigureIntEDMA3();
    }

    /* Function used to Setup ARM Interuppt Controller */
    static void SetupInt(void)
    {
    #ifdef _TMS320C6X
    // Initialize the DSP Interrupt controller
    IntDSPINTCInit();

    // Enable DSP interrupts globally
    IntGlobalEnable();
    #else
    /*Initialize the ARM Interrupt Controller(AINTC). */
    IntAINTCInit();

    /* Enable IRQ in CPSR.*/
    IntMasterIRQEnable();

    /* Enable the interrupts in GER of AINTC.*/
    IntGlobalEnable();

    /* Enable the interrupts in HIER of AINTC.*/
    IntIRQEnable();
    #endif
    }

    /* EDMA3 Completion Handler */
    static void edma3ComplHandler(unsigned int baseAdd, unsigned int regionNum)
    {
    volatile unsigned int pendingIrqs;
    volatile unsigned int isIPR = 0;

    unsigned int indexl;
    unsigned int Cnt = 0;
    indexl = 1;

    #ifdef _TMS320C6X
    IntEventClear(SYS_INT_EDMA3_0_CC0_INT1);
    #else
    IntSystemStatusClear(SYS_INT_CCINT0);
    #endif
    isIPR = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
    if(isIPR)
    {
    while ((Cnt < EDMA3CC_COMPL_HANDLER_RETRY_COUNT)&& (indexl != 0u))
    {
    indexl = 0u;
    pendingIrqs = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
    while (pendingIrqs)
    {
    if((pendingIrqs & 1u) == TRUE)
    {
    /**
    * If the user has not given any callback function
    * while requesting the TCC, its TCC specific bit
    * in the IPR register will NOT be cleared.
    */
    /* here write to ICR to clear the corresponding IPR bits */
    //HWREG(baseAdd + EDMA3CC_S_ICR(regionNum)) = (1u << indexl);

    (*cb_Fxn[indexl])(indexl, EDMA3_XFER_COMPLETE);
    }
    ++indexl;
    pendingIrqs >>= 1u;
    }
    Cnt++;
    }
    }
    }





    static void Edma3ComplHandlerIsr(void)
    {
    #ifdef _TMS320C6X
    // Invoke Completion Handler ISR
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 1);
    #else
    /* Invoke Completion Handler ISR */
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 0);
    #endif
    }

    static void Edma3ComplHandlerIsr1(void)
    {
    #ifdef _TMS320C6X
    // Invoke Completion Handler ISR
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 2);
    #else
    /* Invoke Completion Handler ISR */
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 0);
    #endif
    }

    /* EDMA3 Error Handler */
    static void edma3CCErrHandler(unsigned int baseAdd)
    {
    volatile unsigned int pendingIrqs = 0;
    unsigned int regionNum = 0;
    unsigned int evtqueNum = 0;
    unsigned int index = 1;
    unsigned int Cnt = 0;

    #ifdef _TMS320C6X
    IntEventClear(SYS_INT_EDMA3_0_CC0_ERRINT);
    #else
    IntSystemStatusClear(SYS_INT_CCERRINT);
    #endif

    if((HWREG(baseAdd + EDMA3CC_EMR) != 0 ) || \
    (HWREG(baseAdd + EDMA3CC_QEMR) != 0) || \
    (HWREG(baseAdd + EDMA3CC_CCERR) != 0))
    {
    /* Loop for EDMA3CC_ERR_HANDLER_RETRY_COUNT number of time, breaks
    when no pending interrupt is found */
    while ((Cnt < EDMA3CC_ERR_HANDLER_RETRY_COUNT) && (index != 0u))
    {
    index = 0u;
    pendingIrqs = HWREG(baseAdd + EDMA3CC_EMR);
    while (pendingIrqs)
    {
    /*Process all the pending interrupts*/
    if((pendingIrqs & 1u)==TRUE)
    {
    /* Write to EMCR to clear the corresponding EMR bits.*/
    HWREG(baseAdd + EDMA3CC_EMCR) = (1u<<index);
    /*Clear any SER*/
    HWREG(baseAdd + EDMA3CC_S_SECR(regionNum)) = (1u<<index);
    }
    ++index;
    pendingIrqs >>= 1u;
    }
    index = 0u;
    pendingIrqs = HWREG(baseAdd + EDMA3CC_QEMR);
    while (pendingIrqs)
    {
    /*Process all the pending interrupts*/
    if((pendingIrqs & 1u)==TRUE)
    {
    /* Here write to QEMCR to clear the corresponding QEMR bits*/
    HWREG(baseAdd + EDMA3CC_QEMCR) = (1u<<index);
    /*Clear any QSER*/
    HWREG(baseAdd + EDMA3CC_S_QSECR(0)) = (1u<<index);
    }
    ++index;
    pendingIrqs >>= 1u;
    }
    index = 0u;
    pendingIrqs = HWREG(baseAdd + EDMA3CC_CCERR);
    if (pendingIrqs != 0u)
    {
    /* Process all the pending CC error interrupts. */
    /* Queue threshold error for different event queues.*/
    for (evtqueNum = 0u; evtqueNum < EDMA3_0_NUM_EVTQUE; evtqueNum++)
    {
    if((pendingIrqs & (1u << evtqueNum)) != 0u)
    {
    /* Clear the error interrupt. */
    HWREG(baseAdd + EDMA3CC_CCERRCLR) = (1u << evtqueNum);
    }
    }

    /* Transfer completion code error. */
    if ((pendingIrqs & (1 << EDMA3CC_CCERR_TCCERR_SHIFT)) != 0u)
    {
    HWREG(baseAdd + EDMA3CC_CCERRCLR) = \
    (0x01u << EDMA3CC_CCERR_TCCERR_SHIFT);
    }
    ++index;
    }
    Cnt++;
    }
    }
    }

    static void Edma3CCErrHandlerIsr()
    {
    /* Invoke CC Error Handler ISR */
    edma3CCErrHandler(SOC_EDMA30CC_0_REGS);
    }

    /* Function to register EDMA3 Interuppts */
    static void ConfigureIntEDMA3(void)
    {
    /* Register Interrupts Here */

    #ifdef _TMS320C6X
    IntRegister(C674X_MASK_INT4, Edma3ComplHandlerIsr);
    //IntRegister(C674X_MASK_INT6, Edma3ComplHandlerIsr1);
    //IntRegister(C674X_MASK_INT5, Edma3CCErrHandlerIsr);

    IntEventMap(C674X_MASK_INT4, SYS_INT_EDMA3_0_CC0_INT1);
    //IntEventMap(C674X_MASK_INT6, SYS_INT_EDMA3_0_CC0_INT2);
    //IntEventMap(C674X_MASK_INT5, SYS_INT_EDMA3_0_CC0_ERRINT);

    IntEnable(C674X_MASK_INT4);
    IntEnable(C674X_MASK_INT5);
    #else
    IntRegister(SYS_INT_CCINT0, Edma3ComplHandlerIsr);

    IntChannelSet(SYS_INT_CCINT0, 2);

    IntSystemEnable(SYS_INT_CCINT0);

    IntRegister(SYS_INT_CCERRINT, Edma3CCErrHandlerIsr);

    IntChannelSet(SYS_INT_CCERRINT, 2);

    IntSystemEnable(SYS_INT_CCERRINT);
    #endif
    }


    /*
    ** This function is used as a callback from EDMA3 Completion Handler.
    ** UART in DMA Mode is Disabled over here.
    */
    static void callback(unsigned int tccNum, unsigned int status)
    {
    //UARTDMADisable(SOC_UART_0_REGS, (UART_RX_TRIG_LEVEL_1 | UART_FIFO_MODE));
    //flag = 1;
    }

    With regards
    Shalini
  • I see you changed of the original example outside if UART 2 to 1 changed. Did the original example work with just UART0 changes? I think you should attach the code as a file. It is difficult to read within the post.
  • /**
    * \file uartEcho.c
    *
    * \brief This is a sample application file which invokes some APIs
    * from the EDMA3 device abstraction layer as well as UART
    * device abstraction layer to perform configuration, and
    * transfer of data between UART and CPU RAM by the
    * use of EDMA3
    */
    
    /*
    * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the
    * distribution.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    
    #include "psc.h"
    #include "uart.h"
    #include "edma.h"
    #include "string.h"
    #include "hw_types.h"
    #include "uartStdio.h"
    #include "lcdkC6748.h"
    #include "interrupt.h"
    #include "edma_event.h"
    #include "soc_C6748.h"
    #include "hw_psc_C6748.h"
    
    /****************************************************************************/
    /* INTERNAL MACRO DEFINITIONS */
    /****************************************************************************/
    #define UART_RBR_THR_REG ((0x01C42000u) + (0u))
    
    #define MAX_ACNT 1
    #define MAX_CCNT 1
    
    #define RX_BUFFER_SIZE 20
    
    /* EDMA3 Event queue number. */
    #define EVT_QUEUE_NUM 16
    
    /****************************************************************************/
    /* LOCAL FUNCTION PROTOTYPES */
    /****************************************************************************/
    static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
    volatile char *buffer, unsigned int buffLength);
    
    /* Callback Function Declaration*/
    static void (*cb_Fxn[EDMA3_NUM_TCC]) (unsigned int tcc, unsigned int status);
    static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
    volatile char *buffer);
    static void callback(unsigned int tccNum, unsigned int status);
    static void ConfigureIntEDMA3(void);
    static void Edma3ComplHandlerIsr(void);
    static void Edma3ComplHandlerIsr1(void);
    static void Edma3CCErrHandlerIsr(void);
    static void EDMA3Initialize(void);
    static void SetupInt(void);
    
    /****************************************************************************/
    /* GLOBAL VARIABLES */
    /****************************************************************************/
    volatile unsigned int flag = 0;
    
    /****************************************************************************/
    /* LOCAL FUNCTION DEFINITIONS */
    /****************************************************************************/
    
    /*
    ** Main function.
    */
    
    int main(void)
    {
    //volatile char enter[] ={130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126,8,98,158,142,75,118,106,252,16,197,61,28,150,236,213,248,33,138,122,57,45,217,171,240,67,20,244,114,91,179,87,224,134,41,232,228,183,102,175,193,12,83,209,201,110,205,95,130,24,167,163,146,221,154,191,4,49,79,71,37,187,53,126};
    char buffer[RX_BUFFER_SIZE];
    unsigned int buffLength = 0;
    
    int cnt=0,cnt1=0,j1=0;
    char enter[7];
    for(cnt=0;cnt<7;cnt++)
    enter[cnt]=5;
    
    /* Initialize EDMA3 Controller */
    EDMA3Initialize();
    
    /* Initialize UART */
    // UARTStdioInit();
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_UART0, PSC_POWERDOMAIN_ALWAYS_ON,
    PSC_MDCTL_NEXT_ENABLE);
    UARTPinMuxSetup(0, FALSE);
    UARTEnable(SOC_UART_0_REGS);
    
    /* Configuring the UART parameters*/
    /* 8-bit work length, no parity, 1 stop bit. */
    /* The UART module input frequency shall be 150MHz.*/
    UARTConfigSetExpClk(SOC_UART_0_REGS,
    SOC_UART_0_MODULE_FREQ,
    BAUD_115200,
    UART_WORDL_8BITS,
    UART_OVER_SAMP_RATE_16);
    
    
    /* Enables FIFO mode for transmitter and receiver.*/
    UARTFIFOEnable(SOC_UART_0_REGS);
    
    /* Sets the receiver FIFO Trigger level.*/
    UARTFIFOLevelSet(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1);
    
    
    
    
    /* Request DMA Channel and TCC for UART Transmit*/
    EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
    EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
    EVT_QUEUE_NUM);
    
    /* Registering Callback Function for TX*/
    cb_Fxn[EDMA3_CHA_UART0_TX] = &callback;
    
    EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
    EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX,
    EVT_QUEUE_NUM);
    
    cb_Fxn[EDMA3_CHA_UART0_RX] = &callback;
    
    /* Used for bCnt */
    //buffLength = strlen((const char *) enter);
    buffLength=sizeof(enter);
    
    //while(1)
    //{
    /* Transmit Data for Enter Message */
    UartTransmitData(EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
    enter, buffLength);
    
    /* Enabling UART in DMA Mode*/
    
    UartReceiveData(EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX, buffer);
    
    
    UARTDMAEnable(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1 | \
    UART_DMAMODE | \
    UART_FIFO_MODE );
    
    /* Wait for control to return from call-back function */
    while(1);
    
    //}
    /* Receive Data for Input */
    
    EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
    EDMA3_CHA_UART0_TX, EDMA3_TRIG_MODE_EVENT,
    EDMA3_CHA_UART0_TX, EVT_QUEUE_NUM);
    
    EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
    EDMA3_CHA_UART0_RX, EDMA3_TRIG_MODE_EVENT,
    EDMA3_CHA_UART0_RX, EVT_QUEUE_NUM);
    
    
    
    
    }
    
    /*
    ** This function is used to set the PaRAM entries in EDMA3 for the Transmit Channel
    ** of UART. EDMA3 Enable Transfer is also called within this API.
    */
    int myflag1=0;
    static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
    volatile char *buffer, unsigned int buffLength)
    {
    EDMA3CCPaRAMEntry paramSet;
    EDMA3CCPaRAMEntry paramSet1;
    
    paramSet1.srcAddr = (unsigned int) buffer;
    paramSet1.destAddr = UART_RBR_THR_REG;
    paramSet1.aCnt = MAX_ACNT;
    paramSet1.bCnt = (unsigned short)buffLength;
    paramSet1.cCnt = MAX_CCNT;
    
    /* The src index should increment for every byte being transferred. */
    paramSet1.srcBIdx = (short) 2u;
    
    /* The dst index should not be increment since it is a h/w register*/
    paramSet1.destBIdx = (short) 0u;
    
    /* A sync Transfer Mode */
    paramSet1.srcCIdx = (short) 0u;
    paramSet1.destCIdx = (short) 0u;
    paramSet1.linkAddr = 0x01c043c0;
    paramSet1.bCntReload = (unsigned short)0u;
    paramSet1.opt = 0x00000000u;
    // paramSet1.opt |= (EDMA3CC_OPT_DAM );
    // paramSet1.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
    // paramSet1.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);
    paramSet1.opt |=0x00109002;
    
    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, 30, &paramSet1);
    
    /* Fill the PaRAM Set with transfer specific information */
    paramSet.srcAddr = (unsigned short)buffer;
    paramSet.destAddr = UART_RBR_THR_REG;
    paramSet.aCnt = MAX_ACNT;
    paramSet.bCnt = (unsigned short)buffLength;
    paramSet.cCnt = MAX_CCNT;
    
    /* The src index should increment for every byte being transferred. */
    paramSet.srcBIdx = (short) 2u;
    
    /* The dst index should not be increment since it is a h/w register*/
    paramSet.destBIdx = (short) 0u;
    
    /* A sync Transfer Mode */
    paramSet.srcCIdx = (short) 0u;
    paramSet.destCIdx = (short) 0u;
    paramSet.linkAddr = 0x01c043c0;
    paramSet.bCntReload = (unsigned short)0u;
    paramSet.opt = 0x00000000u;
    // paramSet.opt |= (EDMA3CC_OPT_DAM );
    // paramSet.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
    // paramSet.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);
    paramSet.opt |=0x00109002;
    myflag1=paramSet.opt;
    /* Now write the PaRAM Set */
    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);
    
    // 109002
    //409002
    //HWREG(SOC_EDMA30CC_0_REGS + 0x8c0) |=0x00000008;
    
    //HWREG(SOC_EDMA30CC_0_REGS + 0x8c0) |=0x00000100; //for DRAE1
    
    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
    }
    
    /*
    ** This function is used to set the PARAM SET of EDMA3 for the Receive Channel
    ** of UART. EDMA3 Enable Transfer is also called within this API.
    */
    
    int myflag=0;
    static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
    volatile char *buffer)
    {
    EDMA3CCPaRAMEntry paramSet;
    EDMA3CCPaRAMEntry paramSet1;
    
    /* Fill the PaRAM Set with transfer specific information */
    paramSet.srcAddr = UART_RBR_THR_REG;
    paramSet.destAddr = (unsigned int) buffer;
    paramSet.aCnt = MAX_ACNT;
    paramSet.bCnt = 16;
    paramSet.cCnt = MAX_CCNT;
    
    /* The src index should not be increment since it is a h/w register*/
    paramSet.srcBIdx =(short) 0u;
    /* The dest index should incremented for every byte */
    paramSet.destBIdx = (short) 1u;
    
    
    paramSet.srcCIdx = (short) 0u;
    paramSet.destCIdx = (short) 0u;
    paramSet.linkAddr =0x01c043e0;
    paramSet.bCntReload = (unsigned short)0u;
    paramSet.opt = 0x00000000u;
    paramSet.opt |=0x00108001;
    myflag=paramSet.opt;
    
    /* Now write the PaRAM Set */
    
    paramSet1.srcAddr = UART_RBR_THR_REG;
    paramSet1.destAddr = (unsigned int) buffer;
    paramSet1.aCnt = MAX_ACNT;
    paramSet1.bCnt = 16;
    paramSet1.cCnt = MAX_CCNT;
    
    /* The src index should not be increment since it is a h/w register*/
    paramSet1.srcBIdx =(short) 0u;
    /* The dest index should incremented for every byte */
    paramSet1.destBIdx = (short) 1u;
    
    
    paramSet1.srcCIdx = (short) 0u;
    paramSet1.destCIdx = (short) 0u;
    paramSet1.linkAddr = 0x01c043e0;
    paramSet1.bCntReload = (unsigned short)0u;
    paramSet1.opt = 0x00000000u;
    paramSet1.opt |=0x00108001;
    myflag=paramSet1.opt;
    
    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);
    EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, 31, &paramSet1);
    
    // HWREG(SOC_EDMA30CC_0_REGS + 0x8c0) |=0x00000080; //for DRAE2
    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
    }
    
    /* Function used to Initialize EDMA3 */
    static void EDMA3Initialize(void)
    {
    /* Enabling the PSC for EDMA3CC_0.*/
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_CC0, PSC_POWERDOMAIN_ALWAYS_ON,
    PSC_MDCTL_NEXT_ENABLE);
    
    /* Enabling the PSC for EDMA3TC_0.*/
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_TC0, PSC_POWERDOMAIN_ALWAYS_ON,
    PSC_MDCTL_NEXT_ENABLE);
    
    /* Initialization of EDMA3 */
    EDMA3Init(SOC_EDMA30CC_0_REGS, EVT_QUEUE_NUM);
    
    /*
    ** Enable AINTC to handle interuppts. Also enable IRQ interuppt in
    ** ARM processor.
    */
    SetupInt();
    
    /* Register EDMA3 Interrupts */
    ConfigureIntEDMA3();
    }
    
    /* Function used to Setup ARM Interuppt Controller */
    static void SetupInt(void)
    {
    #ifdef _TMS320C6X
    // Initialize the DSP Interrupt controller
    IntDSPINTCInit();
    
    // Enable DSP interrupts globally
    IntGlobalEnable();
    #else
    /*Initialize the ARM Interrupt Controller(AINTC). */
    IntAINTCInit();
    
    /* Enable IRQ in CPSR.*/
    IntMasterIRQEnable();
    
    /* Enable the interrupts in GER of AINTC.*/
    IntGlobalEnable();
    
    /* Enable the interrupts in HIER of AINTC.*/
    IntIRQEnable();
    #endif
    }
    
    /* EDMA3 Completion Handler */
    static void edma3ComplHandler(unsigned int baseAdd, unsigned int regionNum)
    {
    volatile unsigned int pendingIrqs;
    volatile unsigned int isIPR = 0;
    
    unsigned int indexl;
    unsigned int Cnt = 0;
    indexl = 1;
    
    #ifdef _TMS320C6X
    IntEventClear(SYS_INT_EDMA3_0_CC0_INT1);
    #else
    IntSystemStatusClear(SYS_INT_CCINT0);
    #endif
    isIPR = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
    if(isIPR)
    {
    while ((Cnt < EDMA3CC_COMPL_HANDLER_RETRY_COUNT)&& (indexl != 0u))
    {
    indexl = 0u;
    pendingIrqs = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
    while (pendingIrqs)
    {
    if((pendingIrqs & 1u) == TRUE)
    {
    /**
    * If the user has not given any callback function
    * while requesting the TCC, its TCC specific bit
    * in the IPR register will NOT be cleared.
    */
    /* here write to ICR to clear the corresponding IPR bits */
    //HWREG(baseAdd + EDMA3CC_S_ICR(regionNum)) = (1u << indexl);
    
    (*cb_Fxn[indexl])(indexl, EDMA3_XFER_COMPLETE);
    }
    ++indexl;
    pendingIrqs >>= 1u;
    }
    Cnt++;
    }
    }
    }
    
    
    
    
    
    static void Edma3ComplHandlerIsr(void)
    {
    #ifdef _TMS320C6X
    // Invoke Completion Handler ISR
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 1);
    #else
    /* Invoke Completion Handler ISR */
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 0);
    #endif
    }
    
    static void Edma3ComplHandlerIsr1(void)
    {
    #ifdef _TMS320C6X
    // Invoke Completion Handler ISR
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 2);
    #else
    /* Invoke Completion Handler ISR */
    edma3ComplHandler(SOC_EDMA30CC_0_REGS, 0);
    #endif
    }
    
    /* EDMA3 Error Handler */
    static void edma3CCErrHandler(unsigned int baseAdd)
    {
    volatile unsigned int pendingIrqs = 0;
    unsigned int regionNum = 0;
    unsigned int evtqueNum = 0;
    unsigned int index = 1;
    unsigned int Cnt = 0;
    
    #ifdef _TMS320C6X
    IntEventClear(SYS_INT_EDMA3_0_CC0_ERRINT);
    #else
    IntSystemStatusClear(SYS_INT_CCERRINT);
    #endif
    
    if((HWREG(baseAdd + EDMA3CC_EMR) != 0 ) || \
    (HWREG(baseAdd + EDMA3CC_QEMR) != 0) || \
    (HWREG(baseAdd + EDMA3CC_CCERR) != 0))
    {
    /* Loop for EDMA3CC_ERR_HANDLER_RETRY_COUNT number of time, breaks
    when no pending interrupt is found */
    while ((Cnt < EDMA3CC_ERR_HANDLER_RETRY_COUNT) && (index != 0u))
    {
    index = 0u;
    pendingIrqs = HWREG(baseAdd + EDMA3CC_EMR);
    while (pendingIrqs)
    {
    /*Process all the pending interrupts*/
    if((pendingIrqs & 1u)==TRUE)
    {
    /* Write to EMCR to clear the corresponding EMR bits.*/
    HWREG(baseAdd + EDMA3CC_EMCR) = (1u<<index);
    /*Clear any SER*/
    HWREG(baseAdd + EDMA3CC_S_SECR(regionNum)) = (1u<<index);
    }
    ++index;
    pendingIrqs >>= 1u;
    }
    index = 0u;
    pendingIrqs = HWREG(baseAdd + EDMA3CC_QEMR);
    while (pendingIrqs)
    {
    /*Process all the pending interrupts*/
    if((pendingIrqs & 1u)==TRUE)
    {
    /* Here write to QEMCR to clear the corresponding QEMR bits*/
    HWREG(baseAdd + EDMA3CC_QEMCR) = (1u<<index);
    /*Clear any QSER*/
    HWREG(baseAdd + EDMA3CC_S_QSECR(0)) = (1u<<index);
    }
    ++index;
    pendingIrqs >>= 1u;
    }
    index = 0u;
    pendingIrqs = HWREG(baseAdd + EDMA3CC_CCERR);
    if (pendingIrqs != 0u)
    {
    /* Process all the pending CC error interrupts. */
    /* Queue threshold error for different event queues.*/
    for (evtqueNum = 0u; evtqueNum < EDMA3_0_NUM_EVTQUE; evtqueNum++)
    {
    if((pendingIrqs & (1u << evtqueNum)) != 0u)
    {
    /* Clear the error interrupt. */
    HWREG(baseAdd + EDMA3CC_CCERRCLR) = (1u << evtqueNum);
    }
    }
    
    /* Transfer completion code error. */
    if ((pendingIrqs & (1 << EDMA3CC_CCERR_TCCERR_SHIFT)) != 0u)
    {
    HWREG(baseAdd + EDMA3CC_CCERRCLR) = \
    (0x01u << EDMA3CC_CCERR_TCCERR_SHIFT);
    }
    ++index;
    }
    Cnt++;
    }
    }
    }
    
    static void Edma3CCErrHandlerIsr()
    {
    /* Invoke CC Error Handler ISR */
    edma3CCErrHandler(SOC_EDMA30CC_0_REGS);
    }
    
    /* Function to register EDMA3 Interuppts */
    static void ConfigureIntEDMA3(void)
    {
    /* Register Interrupts Here */
    
    #ifdef _TMS320C6X
    IntRegister(C674X_MASK_INT4, Edma3ComplHandlerIsr);
    //IntRegister(C674X_MASK_INT6, Edma3ComplHandlerIsr1);
    //IntRegister(C674X_MASK_INT5, Edma3CCErrHandlerIsr);
    
    IntEventMap(C674X_MASK_INT4, SYS_INT_EDMA3_0_CC0_INT1);
    //IntEventMap(C674X_MASK_INT6, SYS_INT_EDMA3_0_CC0_INT2);
    //IntEventMap(C674X_MASK_INT5, SYS_INT_EDMA3_0_CC0_ERRINT);
    
    IntEnable(C674X_MASK_INT4);
    IntEnable(C674X_MASK_INT5);
    #else
    IntRegister(SYS_INT_CCINT0, Edma3ComplHandlerIsr);
    
    IntChannelSet(SYS_INT_CCINT0, 2);
    
    IntSystemEnable(SYS_INT_CCINT0);
    
    IntRegister(SYS_INT_CCERRINT, Edma3CCErrHandlerIsr);
    
    IntChannelSet(SYS_INT_CCERRINT, 2);
    
    IntSystemEnable(SYS_INT_CCERRINT);
    #endif
    }
    
    
    /*
    ** This function is used as a callback from EDMA3 Completion Handler.
    ** UART in DMA Mode is Disabled over here.
    */
    static void callback(unsigned int tccNum, unsigned int status)
    {
    //UARTDMADisable(SOC_UART_0_REGS, (UART_RX_TRIG_LEVEL_1 | UART_FIFO_MODE));
    //flag = 1;
    }
    Sir,

    I have done just modification to UART2 program with UART0. Since UART2 is connected to USB UART converter it works with hyperterminal, it cant be done with UART0 which comes out as GPIO pin. Attached is the program.

    With Regards

    Shalini

  • You can buy adapters that convert a logic level UART to a USB serial point. I assume you have been using a scope up to this point.

    My experience with DMA is limited to simple DMA transfers between peripherals. Your code is attempting to something more complicated. I pretty sure your use of 0x01c043e0 is not quite right. With this code

    paramSet.linkAddr =0x01c043e0;
    paramSet.bCntReload = (unsigned short)0u;

    The linkAddr is usually used to chain more tha one PaRAM together and is the offset into the PaRAM. It is not an absolute address. The EDMA code uses the macro EDMA3CC_OPT(PaRAMId) to calculate the offset address.

    Attached is what a simple UART DMA loopback might look like. I do not have access to a development environment and I cannot compile it. In theory it should work.

    You have exceeded my limited knowledge of DMA and cannot help you much more. Hopefully you will get more expert response in this thread or your other thread.

    /**
    * \file uartEcho.c
    *
    * \brief This is a sample application file which invokes some APIs
    * from the EDMA3 device abstraction layer as well as UART
    * device abstraction layer to perform configuration, and
    * transfer of data between UART and CPU RAM by the
    * use of EDMA3
    */
    
    /*
    * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the
    * distribution.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    
    #include "psc.h"
    #include "uart.h"
    #include "edma.h"
    #include "string.h"
    #include "hw_types.h"
    #include "uartStdio.h"
    #include "lcdkC6748.h"
    #include "interrupt.h"
    #include "edma_event.h"
    #include "soc_C6748.h"
    #include "hw_psc_C6748.h"
    
    /****************************************************************************/
    /* INTERNAL MACRO DEFINITIONS */
    /****************************************************************************/
    #define UART_RBR_THR_REG ((0x01C42000u) + (0u))
    
    #define MAX_ACNT 1
    #define MAX_CCNT 1
    
    #define BUFFER_SIZE 20
    
    /* EDMA3 Event queue number. */
    #define EVT_QUEUE_NUM 0
    
    /****************************************************************************/
    /* LOCAL FUNCTION PROTOTYPES */
    /****************************************************************************/
    static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
                                 volatile char *buffer, unsigned int buffLength);
    
    /* Callback Function Declaration*/
    static void (*cb_Fxn[EDMA3_NUM_TCC]) (unsigned int tcc, unsigned int status);
    
    static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
                                volatile char *buffer, unsigned int buffLength);
    static void txcallback(unsigned int tccNum, unsigned int status);
    static void rxcallback(unsigned int tccNum, unsigned int status);
    static void ConfigureIntEDMA3(void);
    static void Edma3ComplHandlerIsr(void);
    static void Edma3CCErrHandlerIsr(void);
    static void EDMA3Initialize(void);
    static void SetupInt(void);
    
    /****************************************************************************/
    /* GLOBAL VARIABLES */
    /****************************************************************************/
    volatile unsigned int txflag = 0;
    volatile unsigned int rxflag = 0;
    
    /****************************************************************************/
    /* LOCAL FUNCTION DEFINITIONS */
    /****************************************************************************/
    
    /*
    ** Main function.
    */
    
    int main(void)
    {
      char txbuffer[BUFFER_SIZE];
      char rxbuffer[BUFFER_SIZE];
      int i;
    
      /* Init buffers */
      for(i=0; i<BUFFER_SIZE; i++)
      {
        txbuffer[i]= i;
        rxbuffer[i]= 0;
      }
    
      /* Initialize EDMA3 Controller */
      EDMA3Initialize();
    
      /* Initialize UART */
      // UARTStdioInit();
      PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_UART0, PSC_POWERDOMAIN_ALWAYS_ON,
                       PSC_MDCTL_NEXT_ENABLE);
      UARTPinMuxSetup(0, FALSE);
      UARTEnable(SOC_UART_0_REGS);
    
      /* Configuring the UART parameters*/
      /* 8-bit work length, no parity, 1 stop bit. */
      /* The UART module input frequency shall be 150MHz.*/
      UARTConfigSetExpClk(SOC_UART_0_REGS,
                          SOC_UART_0_MODULE_FREQ,
                          BAUD_115200,
                          UART_WORDL_8BITS,
                          UART_OVER_SAMP_RATE_16);
    
    
      /* Enables FIFO mode for transmitter and receiver.*/
      UARTFIFOEnable(SOC_UART_0_REGS);
    
      /* Sets the receiver FIFO Trigger level.*/
      UARTFIFOLevelSet(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1);
    
      /* Request DMA Channel and TCC for UART Transmit*/
      EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                          EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
                          EVT_QUEUE_NUM);
    
      /* Registering Callback Function for TX*/
      cb_Fxn[EDMA3_CHA_UART0_TX] = &txcallback;
    
      EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                          EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX,
                          EVT_QUEUE_NUM);
    
      /* Registering Callback Function for RX*/
      cb_Fxn[EDMA3_CHA_UART0_RX] = &rxcallback;
    
      /* Receive Data for Input */
      UartReceiveData(EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX,
                      buffer, BUFFER_SIZE);
    
    
      /* Transmit Data for Enter Message */
      UartTransmitData(EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
                       rxbuffer, BUFFER_SIZE);
    
      /* Enabling UART in DMA Mode*/
      UARTDMAEnable(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1 |
                                     UART_DMAMODE |
                                     UART_FIFO_MODE );
    
      /* Wait for control to return from call-back function */
      while((txflag ==0) && (rxflag==0);
    
      UARTDMADisable(SOC_UART_0_REGS, (UART_RX_TRIG_LEVEL_1 | UART_FIFO_MODE));
    
      EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                       EDMA3_CHA_UART0_TX, EDMA3_TRIG_MODE_EVENT,
                       EDMA3_CHA_UART0_TX, EVT_QUEUE_NUM);
    
      EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                       EDMA3_CHA_UART0_RX, EDMA3_TRIG_MODE_EVENT,
                       EDMA3_CHA_UART0_RX, EVT_QUEUE_NUM);
    
      /* Compare buffers, i = BUFFER_SIZE means good.  */
      for(i=0; i<BUFFER_SIZE; i++)
      {
        if(txbuffer[i] != rxbuffer[i])
          break;
      }
      /* i = BUFFER_SIZE means match  */
    
    
      while(1);
    }
    
    /*
    ** This function is used to set the PaRAM entries in EDMA3 for the Transmit Channel
    ** of UART. EDMA3 Enable Transfer is also called within this API.
    */
    
    static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
                                 volatile char *buffer, unsigned int buffLength)
    {
      EDMA3CCPaRAMEntry paramSet;
    
      /* Fill the PaRAM Set with transfer specific information */
      paramSet.srcAddr = (unsigned int) buffer;
      paramSet.destAddr = UART_RBR_THR_REG;
      paramSet.aCnt = MAX_ACNT;
      paramSet.bCnt = (unsigned short) buffLength;
      paramSet.cCnt = MAX_CCNT;
    
      /* The src index should increment for every byte being transferred. */
      paramSet.srcBIdx = (short) 1u;
    
      /* The dst index should not be increment since it is a h/w register*/
      paramSet.destBIdx = (short) 0u;
      
      /* A sync Transfer Mode */
      paramSet.srcCIdx = (short) 0u;
      paramSet.destCIdx = (short) 0u;
      paramSet.linkAddr = (unsigned short)0xFFFFu;
      paramSet.bCntReload = (unsigned short)0u;
      paramSet.opt = 0x00000000u;
      paramSet.opt |= (EDMA3CC_OPT_DAM );
      paramSet.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
      paramSet.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);
    
      /* Now write the PaRAM Set */
      EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);
    
      /* Enable EDMA Transfer */
      EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
    }
    
    /*
    ** This function is used to set the PARAM SET of EDMA3 for the Receive Channel
    ** of UART. EDMA3 Enable Transfer is also called within this API.
    */
    
    static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
                                volatile char *buffer, unsigned int buffLength)
    {
      EDMA3CCPaRAMEntry paramSet;
    
      /* Fill the PaRAM Set with transfer specific information */
      paramSet.srcAddr = UART_RBR_THR_REG;
      paramSet.destAddr = (unsigned int) buffer;
      paramSet.aCnt = MAX_ACNT;
      paramSet.bCnt = buffLength;
      paramSet.cCnt = MAX_CCNT;
    
      /* The src index should not be increment since it is a h/w register*/
      paramSet.srcBIdx = 0;
      /* The dest index should incremented for every byte */
      paramSet.destBIdx = 1;
    
      /* A sync Transfer Mode */
      paramSet.srcCIdx = 0;
      paramSet.destCIdx = 0;
      paramSet.linkAddr = (unsigned short)0xFFFFu;
      paramSet.bCntReload = 0;
      paramSet.opt = 0x00000000u;    
      paramSet.opt |= ((EDMA3CC_OPT_SAM) << EDMA3CC_OPT_SAM_SHIFT); 
      paramSet.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
      paramSet.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);
    
      /* Now write the PaRAM Set */
      EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);
    
      /* Enable EDMA Transfer */
      EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
    }
    
    /* Function used to Initialize EDMA3 */
    static void EDMA3Initialize(void)
    {
      /* Enabling the PSC for EDMA3CC_0.*/
      PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_CC0, PSC_POWERDOMAIN_ALWAYS_ON,
                       PSC_MDCTL_NEXT_ENABLE);
    
      /* Enabling the PSC for EDMA3TC_0.*/
      PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_TC0, PSC_POWERDOMAIN_ALWAYS_ON,
                       PSC_MDCTL_NEXT_ENABLE);
    
      /* Initialization of EDMA3 */
      EDMA3Init(SOC_EDMA30CC_0_REGS, EVT_QUEUE_NUM);
    
      /*
      ** Enable AINTC to handle interuppts. Also enable IRQ interuppt in
      ** ARM processor.
      */
      SetupInt();
    
      /* Register EDMA3 Interrupts */
      ConfigureIntEDMA3();
    }
    
    /* Function used to Setup ARM Interuppt Controller */
    static void SetupInt(void)
    {
    #ifdef _TMS320C6X
      // Initialize the DSP Interrupt controller
      IntDSPINTCInit();
    
      // Enable DSP interrupts globally
      IntGlobalEnable();
    #else
      /*Initialize the ARM Interrupt Controller(AINTC). */
      IntAINTCInit();
    
      /* Enable IRQ in CPSR.*/
      IntMasterIRQEnable();
    
      /* Enable the interrupts in GER of AINTC.*/
      IntGlobalEnable();
    
      /* Enable the interrupts in HIER of AINTC.*/
      IntIRQEnable();
    #endif
    }
    
    /* EDMA3 Completion Handler */
    static void edma3ComplHandler(unsigned int baseAdd, unsigned int regionNum)
    {
      volatile unsigned int pendingIrqs;
      volatile unsigned int isIPR = 0;
    
      unsigned int indexl;
      unsigned int Cnt = 0;
      indexl = 1;
    
    #ifdef _TMS320C6X
      IntEventClear(SYS_INT_EDMA3_0_CC0_INT1);
    #else
      IntSystemStatusClear(SYS_INT_CCINT0);
    #endif
      isIPR = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
      if(isIPR)
      {
        while ((Cnt < EDMA3CC_COMPL_HANDLER_RETRY_COUNT)&& (indexl != 0u))
        {
          indexl = 0u;
          pendingIrqs = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
          while (pendingIrqs)
          {
            if((pendingIrqs & 1u) == TRUE)
            {
              /**
              * If the user has not given any callback function
              * while requesting the TCC, its TCC specific bit
              * in the IPR register will NOT be cleared.
              */
              /* here write to ICR to clear the corresponding IPR bits */
              HWREG(baseAdd + EDMA3CC_S_ICR(regionNum)) = (1u << indexl);
    
              (*cb_Fxn[indexl])(indexl, EDMA3_XFER_COMPLETE);
            }
            ++indexl;
            pendingIrqs >>= 1u;
          }
          Cnt++;
        }
      }
    }
    
    
    
    
    
    static void Edma3ComplHandlerIsr(void)
    {
    #ifdef _TMS320C6X
      // Invoke Completion Handler ISR
      edma3ComplHandler(SOC_EDMA30CC_0_REGS, 1);
    #else
      /* Invoke Completion Handler ISR */
      edma3ComplHandler(SOC_EDMA30CC_0_REGS, 0);
    #endif
    }
    
    /* EDMA3 Error Handler */
    static void edma3CCErrHandler(unsigned int baseAdd)
    {
      volatile unsigned int pendingIrqs = 0;
      unsigned int regionNum = 0;
      unsigned int evtqueNum = 0;
      unsigned int index = 1;
      unsigned int Cnt = 0;
    
    #ifdef _TMS320C6X
      IntEventClear(SYS_INT_EDMA3_0_CC0_ERRINT);
    #else
      IntSystemStatusClear(SYS_INT_CCERRINT);
    #endif
    
      if((HWREG(baseAdd + EDMA3CC_EMR) != 0 ) ||
         (HWREG(baseAdd + EDMA3CC_QEMR) != 0) ||
         (HWREG(baseAdd + EDMA3CC_CCERR) != 0))
      {
        /* Loop for EDMA3CC_ERR_HANDLER_RETRY_COUNT number of time, breaks
           when no pending interrupt is found */
        while ((Cnt < EDMA3CC_ERR_HANDLER_RETRY_COUNT) && (index != 0u))
        {
          index = 0u;
          pendingIrqs = HWREG(baseAdd + EDMA3CC_EMR);
          while (pendingIrqs)
          {
            /*Process all the pending interrupts*/
            if((pendingIrqs & 1u)==TRUE)
            {
              /* Write to EMCR to clear the corresponding EMR bits.*/
              HWREG(baseAdd + EDMA3CC_EMCR) = (1u<<index);
              /*Clear any SER*/
              HWREG(baseAdd + EDMA3CC_S_SECR(regionNum)) = (1u<<index);
            }
            ++index;
            pendingIrqs >>= 1u;
          }
          index = 0u;
          pendingIrqs = HWREG(baseAdd + EDMA3CC_QEMR);
          while (pendingIrqs)
          {
            /*Process all the pending interrupts*/
            if((pendingIrqs & 1u)==TRUE)
            {
              /* Here write to QEMCR to clear the corresponding QEMR bits*/
              HWREG(baseAdd + EDMA3CC_QEMCR) = (1u<<index);
              /*Clear any QSER*/
              HWREG(baseAdd + EDMA3CC_S_QSECR(0)) = (1u<<index);
            }
            ++index;
            pendingIrqs >>= 1u;
          }
          index = 0u;
          pendingIrqs = HWREG(baseAdd + EDMA3CC_CCERR);
          if (pendingIrqs != 0u)
          {
            /* Process all the pending CC error interrupts. */
            /* Queue threshold error for different event queues.*/
            for (evtqueNum = 0u; evtqueNum < EDMA3_0_NUM_EVTQUE; evtqueNum++)
            {
              if((pendingIrqs & (1u << evtqueNum)) != 0u)
              {
                /* Clear the error interrupt. */
                HWREG(baseAdd + EDMA3CC_CCERRCLR) = (1u << evtqueNum);
              }
            }
    
            /* Transfer completion code error. */
            if ((pendingIrqs & (1 << EDMA3CC_CCERR_TCCERR_SHIFT)) != 0u)
            {
              HWREG(baseAdd + EDMA3CC_CCERRCLR) =
                (0x01u << EDMA3CC_CCERR_TCCERR_SHIFT);
            }
            ++index;
          }
          Cnt++;
        }
      }
    }
    
    static void Edma3CCErrHandlerIsr()
    {
      /* Invoke CC Error Handler ISR */
      edma3CCErrHandler(SOC_EDMA30CC_0_REGS);
    }
    
    /* Function to register EDMA3 Interuppts */
    static void ConfigureIntEDMA3(void)
    {
    /* Register Interrupts Here */
    
    #ifdef _TMS320C6X
      IntRegister(C674X_MASK_INT4, Edma3ComplHandlerIsr);
      IntRegister(C674X_MASK_INT5, Edma3CCErrHandlerIsr);
    
      IntEventMap(C674X_MASK_INT4, SYS_INT_EDMA3_0_CC0_INT1);
      IntEventMap(C674X_MASK_INT5, SYS_INT_EDMA3_0_CC0_ERRINT);
    
      IntEnable(C674X_MASK_INT4);
      IntEnable(C674X_MASK_INT5);
    #else
      IntRegister(SYS_INT_CCINT0, Edma3ComplHandlerIsr);
      IntChannelSet(SYS_INT_CCINT0, 2);
      IntSystemEnable(SYS_INT_CCINT0);
      IntRegister(SYS_INT_CCERRINT, Edma3CCErrHandlerIsr);
      IntChannelSet(SYS_INT_CCERRINT, 2);
      IntSystemEnable(SYS_INT_CCERRINT);
    #endif
    }
    
    
    /*
    ** This function is used as a callback from EDMA3 Completion Handler.
    ** UART in DMA Mode is Disabled over here.
    */
    static void txcallback(unsigned int tccNum, unsigned int status)
    {
    //UARTDMADisable(SOC_UART_0_REGS, (UART_RX_TRIG_LEVEL_1 | UART_FIFO_MODE));
      txflag = 1;
    }
    
    static void rxcallback(unsigned int tccNum, unsigned int status)
    {
    //UARTDMADisable(SOC_UART_0_REGS, (UART_RX_TRIG_LEVEL_1 | UART_FIFO_MODE));
      rxflag = 1;
    }

  • Oops. Missed a variable rename. Attached is the correction.

    /**
    * \file uartEcho.c
    *
    * \brief This is a sample application file which invokes some APIs
    * from the EDMA3 device abstraction layer as well as UART
    * device abstraction layer to perform configuration, and
    * transfer of data between UART and CPU RAM by the
    * use of EDMA3
    */
    
    /*
    * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the
    * distribution.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    
    #include "psc.h"
    #include "uart.h"
    #include "edma.h"
    #include "string.h"
    #include "hw_types.h"
    #include "uartStdio.h"
    #include "lcdkC6748.h"
    #include "interrupt.h"
    #include "edma_event.h"
    #include "soc_C6748.h"
    #include "hw_psc_C6748.h"
    
    /****************************************************************************/
    /* INTERNAL MACRO DEFINITIONS */
    /****************************************************************************/
    #define UART_RBR_THR_REG ((0x01C42000u) + (0u))
    
    #define MAX_ACNT 1
    #define MAX_CCNT 1
    
    #define BUFFER_SIZE 20
    
    /* EDMA3 Event queue number. */
    #define EVT_QUEUE_NUM 0
    
    /****************************************************************************/
    /* LOCAL FUNCTION PROTOTYPES */
    /****************************************************************************/
    static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
                                 volatile char *buffer, unsigned int buffLength);
    
    /* Callback Function Declaration*/
    static void (*cb_Fxn[EDMA3_NUM_TCC]) (unsigned int tcc, unsigned int status);
    
    static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
                                volatile char *buffer, unsigned int buffLength);
    static void txcallback(unsigned int tccNum, unsigned int status);
    static void rxcallback(unsigned int tccNum, unsigned int status);
    static void ConfigureIntEDMA3(void);
    static void Edma3ComplHandlerIsr(void);
    static void Edma3CCErrHandlerIsr(void);
    static void EDMA3Initialize(void);
    static void SetupInt(void);
    
    /****************************************************************************/
    /* GLOBAL VARIABLES */
    /****************************************************************************/
    volatile unsigned int txflag = 0;
    volatile unsigned int rxflag = 0;
    
    /****************************************************************************/
    /* LOCAL FUNCTION DEFINITIONS */
    /****************************************************************************/
    
    /*
    ** Main function.
    */
    
    int main(void)
    {
      char txbuffer[BUFFER_SIZE];
      char rxbuffer[BUFFER_SIZE];
      int i;
    
      /* Init buffers */
      for(i=0; i<BUFFER_SIZE; i++)
      {
        txbuffer[i]= i;
        rxbuffer[i]= 0;
      }
    
      /* Initialize EDMA3 Controller */
      EDMA3Initialize();
    
      /* Initialize UART */
      // UARTStdioInit();
      PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_UART0, PSC_POWERDOMAIN_ALWAYS_ON,
                       PSC_MDCTL_NEXT_ENABLE);
      UARTPinMuxSetup(0, FALSE);
      UARTEnable(SOC_UART_0_REGS);
    
      /* Configuring the UART parameters*/
      /* 8-bit work length, no parity, 1 stop bit. */
      /* The UART module input frequency shall be 150MHz.*/
      UARTConfigSetExpClk(SOC_UART_0_REGS,
                          SOC_UART_0_MODULE_FREQ,
                          BAUD_115200,
                          UART_WORDL_8BITS,
                          UART_OVER_SAMP_RATE_16);
    
    
      /* Enables FIFO mode for transmitter and receiver.*/
      UARTFIFOEnable(SOC_UART_0_REGS);
    
      /* Sets the receiver FIFO Trigger level.*/
      UARTFIFOLevelSet(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1);
    
      /* Request DMA Channel and TCC for UART Transmit*/
      EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                          EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
                          EVT_QUEUE_NUM);
    
      /* Registering Callback Function for TX*/
      cb_Fxn[EDMA3_CHA_UART0_TX] = &txcallback;
    
      EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                          EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX,
                          EVT_QUEUE_NUM);
    
      /* Registering Callback Function for RX*/
      cb_Fxn[EDMA3_CHA_UART0_RX] = &rxcallback;
    
      /* Receive Data for Input */
      UartReceiveData(EDMA3_CHA_UART0_RX, EDMA3_CHA_UART0_RX,
                      rxbuffer, BUFFER_SIZE);
    
    
      /* Transmit Data for Enter Message */
      UartTransmitData(EDMA3_CHA_UART0_TX, EDMA3_CHA_UART0_TX,
                       txbuffer, BUFFER_SIZE);
    
      /* Enabling UART in DMA Mode*/
      UARTDMAEnable(SOC_UART_0_REGS, UART_RX_TRIG_LEVEL_1 |
                                     UART_DMAMODE |
                                     UART_FIFO_MODE );
    
      /* Wait for control to return from call-back function */
      while((txflag ==0) && (rxflag==0);
    
      UARTDMADisable(SOC_UART_0_REGS, (UART_RX_TRIG_LEVEL_1 | UART_FIFO_MODE));
    
      EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                       EDMA3_CHA_UART0_TX, EDMA3_TRIG_MODE_EVENT,
                       EDMA3_CHA_UART0_TX, EVT_QUEUE_NUM);
    
      EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                       EDMA3_CHA_UART0_RX, EDMA3_TRIG_MODE_EVENT,
                       EDMA3_CHA_UART0_RX, EVT_QUEUE_NUM);
    
      /* Compare buffers, i = BUFFER_SIZE means good.  */
      for(i=0; i<BUFFER_SIZE; i++)
      {
        if(txbuffer[i] != rxbuffer[i])
          break;
      }
      /* i = BUFFER_SIZE means match  */
    
    
      while(1);
    }
    
    /*
    ** This function is used to set the PaRAM entries in EDMA3 for the Transmit Channel
    ** of UART. EDMA3 Enable Transfer is also called within this API.
    */
    
    static void UartTransmitData(unsigned int tccNum, unsigned int chNum,
                                 volatile char *buffer, unsigned int buffLength)
    {
      EDMA3CCPaRAMEntry paramSet;
    
      /* Fill the PaRAM Set with transfer specific information */
      paramSet.srcAddr = (unsigned int) buffer;
      paramSet.destAddr = UART_RBR_THR_REG;
      paramSet.aCnt = MAX_ACNT;
      paramSet.bCnt = (unsigned short) buffLength;
      paramSet.cCnt = MAX_CCNT;
    
      /* The src index should increment for every byte being transferred. */
      paramSet.srcBIdx = (short) 1u;
    
      /* The dst index should not be increment since it is a h/w register*/
      paramSet.destBIdx = (short) 0u;
      
      /* A sync Transfer Mode */
      paramSet.srcCIdx = (short) 0u;
      paramSet.destCIdx = (short) 0u;
      paramSet.linkAddr = (unsigned short)0xFFFFu;
      paramSet.bCntReload = (unsigned short)0u;
      paramSet.opt = 0x00000000u;
      paramSet.opt |= (EDMA3CC_OPT_DAM );
      paramSet.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
      paramSet.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);
    
      /* Now write the PaRAM Set */
      EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);
    
      /* Enable EDMA Transfer */
      EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
    }
    
    /*
    ** This function is used to set the PARAM SET of EDMA3 for the Receive Channel
    ** of UART. EDMA3 Enable Transfer is also called within this API.
    */
    
    static void UartReceiveData(unsigned int tccNum, unsigned int chNum,
                                volatile char *buffer, unsigned int buffLength)
    {
      EDMA3CCPaRAMEntry paramSet;
    
      /* Fill the PaRAM Set with transfer specific information */
      paramSet.srcAddr = UART_RBR_THR_REG;
      paramSet.destAddr = (unsigned int) buffer;
      paramSet.aCnt = MAX_ACNT;
      paramSet.bCnt = buffLength;
      paramSet.cCnt = MAX_CCNT;
    
      /* The src index should not be increment since it is a h/w register*/
      paramSet.srcBIdx = 0;
      /* The dest index should incremented for every byte */
      paramSet.destBIdx = 1;
    
      /* A sync Transfer Mode */
      paramSet.srcCIdx = 0;
      paramSet.destCIdx = 0;
      paramSet.linkAddr = (unsigned short)0xFFFFu;
      paramSet.bCntReload = 0;
      paramSet.opt = 0x00000000u;    
      paramSet.opt |= ((EDMA3CC_OPT_SAM) << EDMA3CC_OPT_SAM_SHIFT); 
      paramSet.opt |= ((tccNum << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC);
      paramSet.opt |= (1 << EDMA3CC_OPT_TCINTEN_SHIFT);
    
      /* Now write the PaRAM Set */
      EDMA3SetPaRAM(SOC_EDMA30CC_0_REGS, chNum, &paramSet);
    
      /* Enable EDMA Transfer */
      EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, chNum, EDMA3_TRIG_MODE_EVENT);
    }
    
    /* Function used to Initialize EDMA3 */
    static void EDMA3Initialize(void)
    {
      /* Enabling the PSC for EDMA3CC_0.*/
      PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_CC0, PSC_POWERDOMAIN_ALWAYS_ON,
                       PSC_MDCTL_NEXT_ENABLE);
    
      /* Enabling the PSC for EDMA3TC_0.*/
      PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_TC0, PSC_POWERDOMAIN_ALWAYS_ON,
                       PSC_MDCTL_NEXT_ENABLE);
    
      /* Initialization of EDMA3 */
      EDMA3Init(SOC_EDMA30CC_0_REGS, EVT_QUEUE_NUM);
    
      /*
      ** Enable AINTC to handle interuppts. Also enable IRQ interuppt in
      ** ARM processor.
      */
      SetupInt();
    
      /* Register EDMA3 Interrupts */
      ConfigureIntEDMA3();
    }
    
    /* Function used to Setup ARM Interuppt Controller */
    static void SetupInt(void)
    {
    #ifdef _TMS320C6X
      // Initialize the DSP Interrupt controller
      IntDSPINTCInit();
    
      // Enable DSP interrupts globally
      IntGlobalEnable();
    #else
      /*Initialize the ARM Interrupt Controller(AINTC). */
      IntAINTCInit();
    
      /* Enable IRQ in CPSR.*/
      IntMasterIRQEnable();
    
      /* Enable the interrupts in GER of AINTC.*/
      IntGlobalEnable();
    
      /* Enable the interrupts in HIER of AINTC.*/
      IntIRQEnable();
    #endif
    }
    
    /* EDMA3 Completion Handler */
    static void edma3ComplHandler(unsigned int baseAdd, unsigned int regionNum)
    {
      volatile unsigned int pendingIrqs;
      volatile unsigned int isIPR = 0;
    
      unsigned int indexl;
      unsigned int Cnt = 0;
      indexl = 1;
    
    #ifdef _TMS320C6X
      IntEventClear(SYS_INT_EDMA3_0_CC0_INT1);
    #else
      IntSystemStatusClear(SYS_INT_CCINT0);
    #endif
      isIPR = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
      if(isIPR)
      {
        while ((Cnt < EDMA3CC_COMPL_HANDLER_RETRY_COUNT)&& (indexl != 0u))
        {
          indexl = 0u;
          pendingIrqs = HWREG(baseAdd + EDMA3CC_S_IPR(regionNum));
          while (pendingIrqs)
          {
            if((pendingIrqs & 1u) == TRUE)
            {
              /**
              * If the user has not given any callback function
              * while requesting the TCC, its TCC specific bit
              * in the IPR register will NOT be cleared.
              */
              /* here write to ICR to clear the corresponding IPR bits */
              HWREG(baseAdd + EDMA3CC_S_ICR(regionNum)) = (1u << indexl);
    
              (*cb_Fxn[indexl])(indexl, EDMA3_XFER_COMPLETE);
            }
            ++indexl;
            pendingIrqs >>= 1u;
          }
          Cnt++;
        }
      }
    }
    
    
    
    
    
    static void Edma3ComplHandlerIsr(void)
    {
    #ifdef _TMS320C6X
      // Invoke Completion Handler ISR
      edma3ComplHandler(SOC_EDMA30CC_0_REGS, 1);
    #else
      /* Invoke Completion Handler ISR */
      edma3ComplHandler(SOC_EDMA30CC_0_REGS, 0);
    #endif
    }
    
    /* EDMA3 Error Handler */
    static void edma3CCErrHandler(unsigned int baseAdd)
    {
      volatile unsigned int pendingIrqs = 0;
      unsigned int regionNum = 0;
      unsigned int evtqueNum = 0;
      unsigned int index = 1;
      unsigned int Cnt = 0;
    
    #ifdef _TMS320C6X
      IntEventClear(SYS_INT_EDMA3_0_CC0_ERRINT);
    #else
      IntSystemStatusClear(SYS_INT_CCERRINT);
    #endif
    
      if((HWREG(baseAdd + EDMA3CC_EMR) != 0 ) ||
         (HWREG(baseAdd + EDMA3CC_QEMR) != 0) ||
         (HWREG(baseAdd + EDMA3CC_CCERR) != 0))
      {
        /* Loop for EDMA3CC_ERR_HANDLER_RETRY_COUNT number of time, breaks
           when no pending interrupt is found */
        while ((Cnt < EDMA3CC_ERR_HANDLER_RETRY_COUNT) && (index != 0u))
        {
          index = 0u;
          pendingIrqs = HWREG(baseAdd + EDMA3CC_EMR);
          while (pendingIrqs)
          {
            /*Process all the pending interrupts*/
            if((pendingIrqs & 1u)==TRUE)
            {
              /* Write to EMCR to clear the corresponding EMR bits.*/
              HWREG(baseAdd + EDMA3CC_EMCR) = (1u<<index);
              /*Clear any SER*/
              HWREG(baseAdd + EDMA3CC_S_SECR(regionNum)) = (1u<<index);
            }
            ++index;
            pendingIrqs >>= 1u;
          }
          index = 0u;
          pendingIrqs = HWREG(baseAdd + EDMA3CC_QEMR);
          while (pendingIrqs)
          {
            /*Process all the pending interrupts*/
            if((pendingIrqs & 1u)==TRUE)
            {
              /* Here write to QEMCR to clear the corresponding QEMR bits*/
              HWREG(baseAdd + EDMA3CC_QEMCR) = (1u<<index);
              /*Clear any QSER*/
              HWREG(baseAdd + EDMA3CC_S_QSECR(0)) = (1u<<index);
            }
            ++index;
            pendingIrqs >>= 1u;
          }
          index = 0u;
          pendingIrqs = HWREG(baseAdd + EDMA3CC_CCERR);
          if (pendingIrqs != 0u)
          {
            /* Process all the pending CC error interrupts. */
            /* Queue threshold error for different event queues.*/
            for (evtqueNum = 0u; evtqueNum < EDMA3_0_NUM_EVTQUE; evtqueNum++)
            {
              if((pendingIrqs & (1u << evtqueNum)) != 0u)
              {
                /* Clear the error interrupt. */
                HWREG(baseAdd + EDMA3CC_CCERRCLR) = (1u << evtqueNum);
              }
            }
    
            /* Transfer completion code error. */
            if ((pendingIrqs & (1 << EDMA3CC_CCERR_TCCERR_SHIFT)) != 0u)
            {
              HWREG(baseAdd + EDMA3CC_CCERRCLR) =
                (0x01u << EDMA3CC_CCERR_TCCERR_SHIFT);
            }
            ++index;
          }
          Cnt++;
        }
      }
    }
    
    static void Edma3CCErrHandlerIsr()
    {
      /* Invoke CC Error Handler ISR */
      edma3CCErrHandler(SOC_EDMA30CC_0_REGS);
    }
    
    /* Function to register EDMA3 Interuppts */
    static void ConfigureIntEDMA3(void)
    {
    /* Register Interrupts Here */
    
    #ifdef _TMS320C6X
      IntRegister(C674X_MASK_INT4, Edma3ComplHandlerIsr);
      IntRegister(C674X_MASK_INT5, Edma3CCErrHandlerIsr);
    
      IntEventMap(C674X_MASK_INT4, SYS_INT_EDMA3_0_CC0_INT1);
      IntEventMap(C674X_MASK_INT5, SYS_INT_EDMA3_0_CC0_ERRINT);
    
      IntEnable(C674X_MASK_INT4);
      IntEnable(C674X_MASK_INT5);
    #else
      IntRegister(SYS_INT_CCINT0, Edma3ComplHandlerIsr);
      IntChannelSet(SYS_INT_CCINT0, 2);
      IntSystemEnable(SYS_INT_CCINT0);
      IntRegister(SYS_INT_CCERRINT, Edma3CCErrHandlerIsr);
      IntChannelSet(SYS_INT_CCERRINT, 2);
      IntSystemEnable(SYS_INT_CCERRINT);
    #endif
    }
    
    
    /*
    ** This function is used as a callback from EDMA3 Completion Handler.
    ** UART in DMA Mode is Disabled over here.
    */
    static void txcallback(unsigned int tccNum, unsigned int status)
    {
    //UARTDMADisable(SOC_UART_0_REGS, (UART_RX_TRIG_LEVEL_1 | UART_FIFO_MODE));
      txflag = 1;
    }
    
    static void rxcallback(unsigned int tccNum, unsigned int status)
    {
    //UARTDMADisable(SOC_UART_0_REGS, (UART_RX_TRIG_LEVEL_1 | UART_FIFO_MODE));
      rxflag = 1;
    }