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.

Do you have sample UART Code for UART0 or UART1 ?

Other Parts Discussed in Thread: OMAPL138

Dear Community,

As per my previous post suggestion I have sorted R206, R209, R218, R219. I am able to run UARTEcho of starterware which is written for USB-UART but when I am changing the sample code error is not there but it is also not showing output. 

Do you have any running demo code for UART0 or UART1 or please suggest what are the changes required in UART2 sample starterware code?

With regards,

AS

  • Dear Amlan,
    Have you removed the R205 & R208 for UART1 ?

    To enable UART1 port,
    Need to remove the R205 and R208
    Need to short the R206 and R209

    To enable UART0 port,
    Need to remove the R172, R173 and R277
    Need to short the R218 and R219
  • No Sir,

    I have just sorted and not removed any component. Do after removing R205, R209, R172, R173, R277 will it affect face detection demo ?

    Do the code is right?
    e2e.ti.com/.../1803083

    With regards,
    AS

  • Do the code is right?
    e2e.ti.com/.../1803083

    Your code looks good.

    I have just sorted and not removed any component. Do after removing R205, R209, R172, R173, R277 will it affect face detection demo ?

    No, it won't affect facedetect part.
  • Dear Titusrathinaraj,
    Before sorting R206 and R209 tx and rx of UART1 had no o/p. Pins were not connected.
    After sorting o/p of TX and RX the o/p became 5V.
    After removing the the register R208 (R205 already disconnected) also 5V. It seems tx and rx now connected to dsp processor.

    According to me there are some issues in the code.
    Please suggest where the changes I need to make to run the code.
    With regards,
    AS
  • Sure, let me check and update you.
  • Dear Amlan,

    Can you please try the following code for UART1 ?

    I've changed only one that setup the UART1 interrupt with channel no 2.

    /* Map the channel number 2 of AINTC to UART1 system interrupt. */
    IntChannelSet(SYS_INT_UARTINT1, 2);

    PS: For UART0, you need some more changes in PSC side.
    Like,

    /* Enabling the PSC for UART0.*/
    /* Titus : UART0 is in PSC0 domain, please refer OMAPL138 TRM, PSC section, table 9.1 */
    PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_UART0, PSC_POWERDOMAIN_ALWAYS_ON,
    PSC_MDCTL_NEXT_ENABLE);


    Code:

    /**
    * \file uartEcho.c
    *
    * \brief This is a sample application file which invokes some APIs
    * from the UART device abstraction library to perform configuration,
    * transmission and reception operations.
    */

    /*
    * 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 "hw_psc_C6748.h"
    #include "soc_C6748.h"
    #include "interrupt.h"
    #include "lcdkC6748.h"
    #include "hw_types.h"
    #include "uart.h"
    #include "psc.h"

    /****************************************************************************/
    /* LOCAL FUNCTION PROTOTYPES */
    /****************************************************************************/
    static void ConfigureIntUART(void);
    static void SetupInt(void);
    static void UARTIsr(void);

    /****************************************************************************/
    /* GLOBAL VARIABLES */
    /****************************************************************************/
    char txArray[] = "StarterWare UART echo application\n\r";

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

    int main(void)
    {
    unsigned int intFlags = 0;
    unsigned int config = 0;

    /* Enabling the PSC for UART1.*/
    PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_UART1, PSC_POWERDOMAIN_ALWAYS_ON,
    PSC_MDCTL_NEXT_ENABLE);

    /* Setup PINMUX */
    UARTPinMuxSetup(1, FALSE);

    /* Enabling the transmitter and receiver*/
    UARTEnable(SOC_UART_1_REGS);

    /* 1 stopbit, 8-bit character, no parity */
    config = UART_WORDL_8BITS;

    /* Configuring the UART parameters*/
    UARTConfigSetExpClk(SOC_UART_1_REGS, SOC_UART_1_MODULE_FREQ,
    BAUD_115200, config,
    UART_OVER_SAMP_RATE_16);

    /* Enabling the FIFO and flushing the Tx and Rx FIFOs.*/
    UARTFIFOEnable(SOC_UART_1_REGS);

    /* Setting the UART Receiver Trigger Level*/
    UARTFIFOLevelSet(SOC_UART_1_REGS, UART_RX_TRIG_LEVEL_1);

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

    /* Configure AINTC to receive and handle UART interrupts. */
    ConfigureIntUART();

    /* Preparing the 'intFlags' variable to be passed as an argument.*/
    intFlags |= (UART_INT_LINE_STAT | \
    UART_INT_TX_EMPTY | \
    UART_INT_RXDATA_CTI);

    /* Enable the Interrupts in UART.*/
    UARTIntEnable(SOC_UART_1_REGS, intFlags);

    while(1);
    }

    /*
    ** \brief Interrupt Service Routine(ISR) to be executed on UART interrupts.
    ** Depending on the source of interrupt, this
    ** 1> writes to the serial communication console, or
    ** 2> reads from the serial communication console, or
    ** 3> reads the byte in RBR if receiver line error has occured.
    */

    static void UARTIsr()
    {
    static unsigned int length = sizeof(txArray);
    static unsigned int count = 0;
    unsigned char rxData = 0;
    unsigned int int_id = 0;

    /* This determines the cause of UART1 interrupt.*/
    int_id = UARTIntStatus(SOC_UART_1_REGS);

    #ifdef _TMS320C6X
    // Clear UART1 system interrupt in DSPINTC
    IntEventClear(SYS_INT_UART1_INT);
    #else
    /* Clears the system interupt status of UART1 in AINTC. */
    IntSystemStatusClear(SYS_INT_UARTINT1);
    #endif

    /* Checked if the cause is transmitter empty condition.*/
    if(UART_INTID_TX_EMPTY == int_id)
    {
    if(0 < length)
    {
    /* Write a byte into the THR if THR is free. */
    UARTCharPutNonBlocking(SOC_UART_1_REGS, txArray[count]);
    length--;
    count++;
    }
    if(0 == length)
    {
    /* Disable the Transmitter interrupt in UART.*/
    UARTIntDisable(SOC_UART_1_REGS, UART_INT_TX_EMPTY);
    }
    }

    /* Check if the cause is receiver data condition.*/
    if(UART_INTID_RX_DATA == int_id)
    {
    rxData = UARTCharGetNonBlocking(SOC_UART_1_REGS);
    UARTCharPutNonBlocking(SOC_UART_1_REGS, rxData);
    }


    /* Check if the cause is receiver line error condition.*/
    if(UART_INTID_RX_LINE_STAT == int_id)
    {
    while(UARTRxErrorGet(SOC_UART_1_REGS))
    {
    /* Read a byte from the RBR if RBR has data.*/
    UARTCharGetNonBlocking(SOC_UART_1_REGS);
    }
    }

    return;
    }

    /*
    ** \brief This function invokes necessary functions to configure the ARM
    ** processor and ARM Interrupt Controller(AINTC) to receive and
    ** handle interrupts.
    */


    static void SetupInt(void)
    {
    #ifdef _TMS320C6X
    // Initialize the DSP INTC
    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
    }

    /*
    ** \brief This function confiugres the AINTC to receive UART interrupts.
    */
    static void ConfigureIntUART(void)
    {
    #ifdef _TMS320C6X
    IntRegister(C674X_MASK_INT4, UARTIsr);
    IntEventMap(C674X_MASK_INT4, SYS_INT_UART1_INT);
    IntEnable(C674X_MASK_INT4);
    #else
    /* Registers the UARTIsr in the Interrupt Vector Table of AINTC. */
    IntRegister(SYS_INT_UARTINT1, UARTIsr);

    /* Map the channel number 2 of AINTC to UART1 system interrupt. */
    IntChannelSet(SYS_INT_UARTINT1, 2);

    IntSystemEnable(SYS_INT_UARTINT1);
    #endif
    }

    /****************************END OF FILE*************************************/
  • Dear Amlan,
    Able to run the UART1 and got the print ??
  • No Sir,
    I didn't get o/p.
    The main issue is o/p of UART1 tx is 0.5V . As it should bo near to 3 V during non communication time.
    but rx have o/p nearly 3 V.
    There may be some hardware error on the particular C6748 LCDK board.
    With regards,
    AS
  • I found one e2e post where the customer is able to work with UART0 and UART1 on LCDK board.
    e2e.ti.com/.../200681