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.

Starterware/AM3359: STARTERWARE UART

Part Number: AM3359
Other Parts Discussed in Thread: SYSBIOS

Tool/software: Starterware

Hi ,

I am currently trying to execute a UART program, its as below:

#include "uart_irda_cir.h"

#include "soc_AM335x.h"

#include "evmAM335x.h"

#include "hw_types.h"

#include <hw_uart_irda_cir.h>

/******************************************************************************

** INTERNAL MACRO DEFINITIONS

******************************************************************************/

#define UART_CONSOLE_BASE (SOC_UART_0_REGS)

#define BAUD_RATE_115200 (115200)

#define UART_MODULE_INPUT_CLK (48000000)

/******************************************************************************

** INTERNAL FUNCTION DECLARATIONS

******************************************************************************/

static void UARTStdioInitExpClk(unsigned int baudRate,

unsigned int rxTrigLevel,

unsigned int txTrigLevel);

static void UartFIFOConfigure(unsigned int txTrigLevel,

unsigned int rxTrigLevel);

static void UartBaudRateSet(unsigned int baudRate);

void UARTConsolePutc(unsigned char data);

unsigned char UARTConsoleGetc(void);

void UARTConsoleInit(void);

/******************************************************************************

** FUNCTION DEFINITIONS

******************************************************************************/

/**

* \brief This function initializes the specified UART instance for use.

* This does the following:

* - Enables the FIFO and performs the FIFO settings\n

* - Performs the Baud Rate settings\n

* - Configures the Line Characteristics to 8-N-1 format\n

*

* \param baudRate The baud rate to be used for communication

* \param rxTrigLevel The receiver FIFO trigger level

* \param txTrigLevel The transmitter FIFO trigger level

*

* \return None

*

* \note By default, a granularity of 1 will be selected for transmitter

* and receiver FIFO trigger levels.

*/

static void UARTStdioInitExpClk(unsigned int baudRate,

unsigned int rxTrigLevel,

unsigned int txTrigLevel)

{

/* Performing a module reset. */

UARTModuleReset(UART_CONSOLE_BASE);

/* Performing FIFO configurations. */

UartFIFOConfigure(txTrigLevel, rxTrigLevel);

/* Performing Baud Rate settings. */

UartBaudRateSet(baudRate);

/* Switching to Configuration Mode B. */

UARTRegConfigModeEnable(UART_CONSOLE_BASE, UART_REG_CONFIG_MODE_B);

/* Programming the Line Characteristics. */

UARTLineCharacConfig(UART_CONSOLE_BASE,

(UART_FRAME_WORD_LENGTH_8 | UART_FRAME_NUM_STB_1),

UART_PARITY_NONE);

/* Disabling write access to Divisor Latches. */

UARTDivisorLatchDisable(UART_CONSOLE_BASE);

/* Disabling Break Control. */

UARTBreakCtl(UART_CONSOLE_BASE, UART_BREAK_COND_DISABLE);

/* Switching to UART16x operating mode. */

UARTOperatingModeSelect(UART_CONSOLE_BASE, UART16x_OPER_MODE);

}

/*

** A wrapper function performing FIFO configurations.

*/

static void UartFIFOConfigure(unsigned int txTrigLevel,

unsigned int rxTrigLevel)

{

unsigned int fifoConfig = 0;

/* Setting the TX and RX FIFO Trigger levels as 1. No DMA enabled. */

fifoConfig = UART_FIFO_CONFIG(UART_TRIG_LVL_GRANULARITY_1,

UART_TRIG_LVL_GRANULARITY_1,

txTrigLevel,

rxTrigLevel,

1,

1,

UART_DMA_EN_PATH_SCR,

UART_DMA_MODE_0_ENABLE);

/* Configuring the FIFO settings. */

UARTFIFOConfig(UART_CONSOLE_BASE, fifoConfig);

}

/*

** A wrapper function performing Baud Rate settings.

*/

static void UartBaudRateSet(unsigned int baudRate)

{

unsigned int divisorValue = 0;

/* Computing the Divisor Value. */

divisorValue = UARTDivisorValCompute(UART_MODULE_INPUT_CLK,

baudRate,

UART16x_OPER_MODE,

UART_MIR_OVERSAMPLING_RATE_42);

/* Programming the Divisor Latches. */

UARTDivisorLatchWrite(UART_CONSOLE_BASE, divisorValue);

}

/**

* \brief This function initializes the specified UART instance for use.

* This does the following:

* - Enables the FIFO and performs the FIFO settings\n

* - Transmitter and Recevier Threshold Levels are 1 byte each\n

* - Baud Rate of 115200 bits per second(bps)\n

* - Configures the Line Characteristics to 8-N-1 format\n

*

* \param None

*

* \return None

*/

void UARTConsoleInit(void)

{

/* Configuring the system clocks for UART0 instance. */

UART0ModuleClkConfig();

/* Performing the Pin Multiplexing for UART0 instance. */

UARTPinMuxSetup(0);

UARTStdioInitExpClk(BAUD_RATE_115200, 1, 1);

}

/**

* \brief This function puts a character on the serial console.

*

* \param data The character to be put on the serial console

*

* \return None.

*/

void UARTConsolePutc(unsigned char data)

{

UARTCharPut(UART_CONSOLE_BASE, data);

}

/**

* \brief This function puts a character on the serial console.

*

* \param none

*

* \return Character as input from the console

*/

unsigned char UARTConsoleGetc(void)

{

return ((unsigned char)UARTCharGet(UART_CONSOLE_BASE));

}

int main()

{

UARTStdioInitExpClk(BAUD_RATE_115200,UART_FCR_TX_TRIG_LVL_56,UART_FCR_RX_TRIG_LVL_8);

UartFIFOConfigure(UART_FCR_TX_TRIG_LVL_56,UART_FCR_RX_TRIG_LVL_8);

UartBaudRateSet(BAUD_RATE_115200);

UARTConsoleInit();

UARTConsolePutc('S');

}

During debugging after the 1903th line i am getting an error as no source available as shown below.

We have included all the necessary source and header files.

Kindly help us to overcome with this issue.

  • Anjana,

    Is this for the ICEv2?

    Any reason you don't want to use the PDK UART example for the ICEv2 instead of writing your own example?
    C:\ti\pdk_am335x_1_0_5\packages\MyExampleProjects\UART_BasicExample_icev2AM335x_armTestProject

    software-dl.ti.com/.../index_FDS.html
    processors.wiki.ti.com/.../Processor_SDK_RTOS_UART
    processors.wiki.ti.com/.../Processor_SDK_RTOS_Software_Developer_Guide

    There's also a UART example in Starterware at:
    C:\ti\pdk_am335x_1_0_5\packages\ti\starterware\examples\uart

    The PDK examples would be a better starting point to develop.

    Hope this helps.

    Lali
  • Hi Lali,

    I tried PDK UART Example.
    I am facing a lot of errors while compiling the dependent codes(DAL,DEVICE, etc)
    I am using CCS6.

    I am new to this, please help me overcome.

    Regards,

    Anjana G

  • Anjana,

    Did you run the pdkprojectcreate.bat file to create the examples? What projects did you import into your workspace.
    Can you attach an error log?

    Lali
  • Lali,

    No i had not run the batch file earlier.
    Now i have done it, can you let me know the steps to execute the UART_BasicExample_icev2AM335x_armTestProject..
    Now i am able to build without any errors but i am not getting any output on the console.

    Please help

    Regards,
    Anjana G

  • Anjana,

    Are you connected to the correct COM port, right baud, etc?
    Do you see the COM port pop-up on your PC device manager?

    Lali
  • Lali,

    Thanks, i ts working fine now.

    I am currently working on ADC(SYSBIOS).
    I have created Hwi statically. Code that i am trying is as below:

    /*
    * ======== main.c ========
    */

    #include <xdc/std.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    #include <ti/sysbios/BIOS.h>
    #include "interrupt.h"
    #include <ti/sysbios/family/arm/a8/Mmu.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/family/arm/a8/intcps/Hwi.h>
    #include <ti/sysbios/hal/Hwi.h>
    #include "consoleUtils.h"
    #include "soc_AM335x.h"
    #include "evmAM335x.h"
    #include "interrupt.h"
    #include "hw_types.h"
    #include "tsc_adc.h"
    #include <stdio.h>

    #define RESOL_X_MILLION (439u)

    volatile unsigned int flag = 1;
    unsigned int sample1;
    //unsigned int sample2;
    unsigned int val1;
    //unsigned int val2;
    unsigned int a,i;

    static void ADCConfigure(void);
    static void CleanUpInterrupts(void);
    static void StepConfigure(unsigned int, unsigned int, unsigned int);

    /*
    * ======== taskFxn ========
    */
    Void taskFxn(UArg a0, UArg a1)
    {
    System_printf("enter taskFxn()\n");

    Task_sleep(10);

    System_printf("exit taskFxn()\n");

    System_flush(); /* force SysMin output to console */
    }


    void ADC_INT(UArg a0)
    {
    ConsoleUtilsInit();
    ConsoleUtilsSetType(CONSOLE_UART);
    //System_printf("Hwi0\n");


    ConsoleUtilsPrintf("ADC configured");
    //System_printf("ADC configured\n");

    while(a0);
    // IntSystemDisable(SYS_INT_ADC_TSC_GENINT);
    // Hwi_disableInterrupt(SYS_INT_ADC_TSC_GENINT);
    ConsoleUtilsPrintf("IntSystemDisable\n\r");

    volatile unsigned int status;
    status = TSCADCIntStatus(SOC_ADC_TSC_0_REGS);
    TSCADCIntStatusClear(SOC_ADC_TSC_0_REGS, status);

    if(status & TSCADC_END_OF_SEQUENCE_INT)
    {
    /* Read data from fifo 0 */
    sample1 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_0);
    val1 = (sample1 * RESOL_X_MILLION) / 1000;
    ConsoleUtilsPrintf("Voltage sensed on the AN0 line : ");
    ConsoleUtilsPrintf("%d", val1);
    //System_printf("Voltage sensed on the AN0 line :");
    //System_printf("%d",val1);
    /* Read data from fifo 1*/
    /*sample2 = TSCADCFIFOADCDataRead(SOC_ADC_TSC_0_REGS, TSCADC_FIFO_1);
    val2 = (sample2 * RESOL_X_MILLION) / 1000;
    ConsoleUtilsPrintf("Voltage sensed on the AN1 line : ");
    ConsoleUtilsPrintf("%d", val2);*/

    //System_printf("Voltage sensed on the AN1 line :");
    //System_printf("%d",val2);
    // IntSystemEnable(SYS_INT_ADC_TSC_GENINT);
    // flag=0;
    BIOS_exit(0);

    }
    }
    /*
    * ======== main ========
    */
    Int main()
    {
    Mmu_disable();
    ADCConfigure();
    Hwi_Handle hwi0;
    Hwi_Params hwi0Params;
    Task_Handle task;
    Error_Block eb;
    Error_init(&eb);
    System_printf("enter main()\n");
    Error_init(&eb);
    task = Task_create(taskFxn, NULL, &eb);
    if (task == NULL)
    {
    System_printf("Task_create() failed!\n");
    BIOS_exit(0);
    }
    Hwi_Params_init(&hwi0Params);
    hwi0 = Hwi_create(16, ADC_INT, &hwi0Params, &eb);
    if (hwi0 == NULL)
    {
    System_printf("hwifailed!\n");
    BIOS_exit(0);
    }
    // Hwi_enableInterrupt(SYS_INT_ADC_TSC_GENINT);


    BIOS_start(); /* does not return */
    return(0);
    }


    static void CleanUpInterrupts(void)
    {
    TSCADCIntStatusClear(SOC_ADC_TSC_0_REGS, 0x7FF);
    TSCADCIntStatusClear(SOC_ADC_TSC_0_REGS ,0x7FF);
    TSCADCIntStatusClear(SOC_ADC_TSC_0_REGS, 0x7FF);
    }

    /* ADC is configured */
    static void ADCConfigure(void)
    {
    /* Enable the clock for touch screen */
    TSCADCModuleClkConfig();

    TSCADCPinMuxSetUp();

    /* Configures ADC to 3Mhz */
    TSCADCConfigureAFEClock(SOC_ADC_TSC_0_REGS, 24000000, 3000000);

    /* Enable Transistor bias */
    TSCADCTSTransistorConfig(SOC_ADC_TSC_0_REGS, TSCADC_TRANSISTOR_DISABLE);

    TSCADCStepIDTagConfig(SOC_ADC_TSC_0_REGS, 1);

    /* Disable Write Protection of Step Configuration regs*/
    TSCADCStepConfigProtectionDisable(SOC_ADC_TSC_0_REGS);

    /* Configure step 1 for channel 1(AN0)*/
    StepConfigure(0, TSCADC_FIFO_0, TSCADC_POSITIVE_INP_CHANNEL1);

    /* Configure step 2 for channel 2(AN1)*/
    StepConfigure(1, TSCADC_FIFO_1, TSCADC_POSITIVE_INP_CHANNEL2);

    /* General purpose inputs */
    TSCADCTSModeConfig(SOC_ADC_TSC_0_REGS, TSCADC_GENERAL_PURPOSE_MODE);

    /* Enable step 1 */
    TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 1, 1);

    /* Enable step 2 */
    TSCADCConfigureStepEnable(SOC_ADC_TSC_0_REGS, 2, 1);

    /* Clear the status of all interrupts */
    CleanUpInterrupts();

    /* End of sequence interrupt is enable */
    TSCADCEventInterruptEnable(SOC_ADC_TSC_0_REGS, TSCADC_END_OF_SEQUENCE_INT);

    /* Enable the TSC_ADC_SS module*/
    TSCADCModuleStateSet(SOC_ADC_TSC_0_REGS, TSCADC_MODULE_ENABLE);
    }

    /* Configures the step */
    void StepConfigure(unsigned int stepSel, unsigned int fifo,
    unsigned int positiveInpChannel)
    {
    /* Configure ADC to Single ended operation mode */
    TSCADCTSStepOperationModeControl(SOC_ADC_TSC_0_REGS,
    TSCADC_SINGLE_ENDED_OPER_MODE, stepSel);

    /* Configure step to select Channel, refernce voltages */
    TSCADCTSStepConfig(SOC_ADC_TSC_0_REGS, stepSel, TSCADC_NEGATIVE_REF_VSSA,
    positiveInpChannel, TSCADC_NEGATIVE_INP_CHANNEL1, TSCADC_POSITIVE_REF_VDDA);

    /* select fifo 0 or 1*/
    TSCADCTSStepFIFOSelConfig(SOC_ADC_TSC_0_REGS, stepSel, fifo);

    /* Configure ADC to one continious mode */
    TSCADCTSStepModeConfig(SOC_ADC_TSC_0_REGS, stepSel, TSCADC_ONE_SHOT_SOFTWARE_ENABLED);
    }

    I am getting this error.
    Can you please help me debug this?

    Regards,
    Anjana 

  • Anjana,

    As the errors has suggested, have you checked the HWI definitions for conflict?
    Do you have a CCS project you can attached for me to take a look?

    Lali
  • Lali,

    CCS project has been attached

    2844.ADC_OS.zip

    After trying to excute the code

    I am getting this error.
    I know i am wrong somewhere.
    Can you please help.

    Regards,
    Anjana