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.

Converting CCS project to RTSC project

Other Parts Discussed in Thread: SYSBIOS, AM3359

Hi,

I am working wih ICEv2 AM3359, CCSv6.1.1 and sysbios 2.1.1.2. I am trying to convert ADC example project that is available on CCS platform to RTSC platform. I created an example project and then added main ADC code to task function in the RTSC project and included the libraries and headers. I am able to build the project successfully but its getting stuck while setting the hardware field which enables the ADC.

HW_WR_FIELD32((baseAddr + ADC0_CTRL),ADC0_CTRL_EN,ADC0_CTRL_EN_ENABLE);

Can someone please guide me in how to rectify this problem.

Any help is appreciated.

Regards 

Rohan

  • Hi Rohan,

    Have you created the ADC interrupt in the kernel (e.g. Hwi_create)? The kernel manages the vector table.

    Todd
  • Hi Todd,

    I am new to RTSC platform. I just included the ADC code except for initialization part in task function of RTSC project. I don't think so that I created ADC interrupt in kernel. 

    Can you guide on which interrupt to be added. I am also attaching my main program code below.

    Thanks & regards 

    Rohan

    /* SysBios header files */
    #include <xdc/std.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/family/arm/a8/Cache.h>
    
    
    #include <console_utils.h>
    
    #include "board_support.h"
    #include "board.h"
    
    #include "soc.h"
    #include "types.h"
    #include "error.h"
    #include "device.h"
    #include "chipdb.h"
    #include "adc_app.h"
    #include "tsc_adc_ss.h"
    
    
    /* ========================================================================== */
    /*                                Macros                                      */
    /* ========================================================================== */
    
    /**
     * \name    Macros used by the application.
     */
    
    /** @{ */
    /* Macro representing the voltage resolution. */
    #define VOLTAGE_RESOLUTION       (439U)
    
    /* Macro representing the module clock of TSCADC. */
    #define TSCADC_MODULE_CLOCK      (24000000U)
    
    /* Macro representing the AFE clock of TSCADC. */
    #define TSCADC_AFE_CLOCK         (3000000U)
    /** @} */
    
    /* ========================================================================== */
    /*                         Structures and Enums                               */
    /* ========================================================================== */
    
    /* None */
    
    /* ========================================================================== */
    /*                 Internal Function Declarations                             */
    /* ========================================================================== */
    
    /**
     * \brief     Fetch the ADC instance address.
     *
     * \param     pObj       Pointer to the ADC application configuration
     *                       structure.
     *
     * \retval    #S_PASS - ADC instance is present.
     * \retVal    #E_FAIL - ADC instance is not present.
     */
    static int32_t AdcAppSocInfoGet(adcAppCfgObj_t *pObj);
    
    /* ========================================================================== */
    /*                            Global Variables                                */
    /* ========================================================================== */
    
    /** \brief Application default configuration */
    static const adcAppCfgObj_t ADCAPPVOLTMEASURE_DEFAULT =
    {
        0U,                           /* instNum */
        0U,                           /* instAddr */
        24000000U,                    /* modClk */
        3000000U,                     /* afeInClk */
        NULL,                         /* pSample */
        {
            FALSE,                    /* diffCtrl */
            0U                        /* fifoSel */
        },
        {
            INTC_TRIG_HIGH_LEVEL,     /* trigType */
            0U,                       /* intrLine */
            16U,                      /* intrPriority */
            FALSE,                    /* isIntrSecure */
            0U,                       /* endOfSeqIntr */
            NULL                      /* pFnIntrHandler */
        },
        {
            ADC_GP_MODE_ENABLE        /* adcMode. */
        }
    };
    
    /** \brief Global object for the ADC volt measure application. */
    static adcAppCfgObj_t gVoltMeasureAppCfg;
    
    /** \brief Variable to hold the sample values. */
    static uint32_t gVoltMeasureAppSampleVal[2U];
    
    
    
    /*
     *  ======== taskFxn and TaskHandle ========
     */
    
    Void ADCtask(UArg a0, UArg a1);
    
    Task_Handle adctask;
    Void ADCtask(UArg a0, UArg a1)
    {
    	int32_t status = S_PASS;
    	uint32_t chan1, chan2 = 0U;
    	CONSOLEUtilsPrintf("\nCheck Point 1\n");
    	gVoltMeasureAppCfg = ADCAPPVOLTMEASURE_DEFAULT;
    	gVoltMeasureAppCfg.pSample = gVoltMeasureAppSampleVal;
    	status = AdcAppSocInfoGet(&gVoltMeasureAppCfg);
    
    	if (S_PASS == status)
    	{
    		CONSOLEUtilsPrintf("\nCheck Point 2\n");
    		/* Initialize the ADC application.*/
    		status = ADCAppInit(&gVoltMeasureAppCfg);
    		CONSOLEUtilsPrintf("\nCheck Point 3\n");
            if (S_PASS == status)
            {
            	CONSOLEUtilsPrintf("\nCheck Point 4\n");
            	/* Wait till the ADC processes the analog lines.*/
               while(1U != gVoltMeasureAppCfg.appIntrCfg.endOfSeqIntr);
               /* Read the sample data from the FIFO.*/
               gVoltMeasureAppSampleVal[0U] = TSCADCFIFOADCDataRead(gVoltMeasureAppCfg.instAddr,
            		   	   	   	   	   TSCADC_FIFO_SEL_0);
               gVoltMeasureAppSampleVal[1U] = TSCADCFIFOADCDataRead(gVoltMeasureAppCfg.instAddr,
    		                       	   TSCADC_FIFO_SEL_1);
    
    		   chan1 = (gVoltMeasureAppSampleVal[0U] * VOLTAGE_RESOLUTION) / 1000U;
               chan2 = (gVoltMeasureAppSampleVal[1U] * VOLTAGE_RESOLUTION) / 1000U;
    
               CONSOLEUtilsPrintf("Voltage sensed on the AN0 line :");
               CONSOLEUtilsPrintf("%dmV\r\n", chan1);
               CONSOLEUtilsPrintf("Voltage sensed on the AN1 line :");
               CONSOLEUtilsPrintf("%dmV\r\n", chan2);
    		 }
    		 else
    		 {
    		    CONSOLEUtilsPrintf("TSCADC initialization failed\n");
    		 }
         }
    	 else
    	 {
    	    CONSOLEUtilsPrintf("Exiting from the application\n");
    	 }
    
    }
    
    int main()
    {
    
        SDKMMUInit(applMmuEntries);   // needed first
        BOARDInit(NULL);
        /* Initialize the UART console */
        CONSOLEUtilsInit();
        /* Select the console type based on compile time check */
        CONSOLEUtilsSetType(CONSOLE_UTILS_TYPE_UART);
        Task_Params taskParams;
        Task_Params_init(&taskParams);
        taskParams.priority = 4;
        taskParams.stackSize = 0x400;
        adctask = Task_create(ADCtask, &taskParams, NULL);
        CONSOLEUtilsPrintf("\nStarterWare ADC voltage measure application!!\n");
    
    
        BIOS_start();     /* enable interrupts and start SYS/BIOS */
        return 0;
    }
    
    static int32_t AdcAppSocInfoGet(adcAppCfgObj_t *pObj)
    	{
    	    int32_t status = E_FAIL;
    
    	    pObj->instNum = 0U;
    
    	    if (TRUE == CHIPDBIsResourcePresent(CHIPDB_MOD_ID_ADC0, pObj->instNum))
    	    {
    	        /* Update the Interrupt Line number */
    	        if(SOC_FAMILY_ID_AM43XX == SOCGetSocFamilyId())
    	        {
    	            pObj->appIntrCfg.intrLine = 48U;
    	        }
    	        else if(SOC_FAMILY_ID_AM335X == SOCGetSocFamilyId())
    	        {
    	            pObj->appIntrCfg.intrLine = 16U;
    	        }
    	        else
    	        {
    	            CONSOLEUtilsPrintf("ADC interrupts not supported on the SOC.\n");
    	        }
    
    	        /* TODO: Need to update the interrupt Numberdata base of ChipDB */
    	        /*
    	        pObj->appIntrCfg.intrLine = ChipDBInterruptNum(CHIPDB_MOD_ID_ADC0,
    	                                          0, 0);
    	        */
    
    	        /* Read the ADC instance number. */
    	        pObj->instAddr = CHIPDBBaseAddress(CHIPDB_MOD_ID_ADC0, 0U);
    
    	        status = S_PASS;
    	    }
    	    else
    	    {
    	       CONSOLEUtilsPrintf("ADC instance is not present on the SOC.\n");
    	    }
    
    	    return(status);
    	}
    

  • Please refer to the ti.sysbios.hal.Hwi documentation in the <bios>/docs/cdoc/index.html documentation for details about the Hwi module. Hwi = HardWare Interrupt.

    Todd
  • Hi Todd,

    I went through the doc, the syntax for the hwi creation involves interrupt id. In sysbios 1.1.0.8 adc interrupt is given by SYS_INT_ADC_TSC_GENINT, whereas in sysbios 2.1.1.2 there is no such named flag. Is there any change of name of flag in the higher version ??

    Regards

    Rohan

  • I move this thread to the device forum.
  • Hi Todd,

    I could find the interrupt line number for the am335x family, and I included Hwi module in the code but I am still facing the same problem. I am attaching my project below, please guide me if I am missing something.

    Thanks & Regards

    Rohan

    Trial 2.rar

  • You probably have not enabled the clocks to the ADC module. You can see the ADC Starterware programming sequence here: processors.wiki.ti.com/.../StarterWare_ADC For RTSC support please go to community forums, this is not supported by TI.
  • In CCS platform adc is working fine and same code I tried to modify in RTSC platform. And there the program is getting stuck while enabling ADC.

    Regards
    Rohan
  • I found the problem, I was using the INTC twice. So i guess it led to some conflict and interrupt wasn't getting enabled. Now I am able to enable the interrupt using Hwi module in RTSC platform.

    Regards
    Rohan