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.

c6678 timer interrupts

Other Parts Discussed in Thread: SYSBIOS

I have a multicore application code based on the multicore example in the PDK which can receive packets from the outside and process them. I am looking to implement a loop which basically will block till it receives a semaphore signal to indicate a 10ms cycle time for each time through the loop after I have setup the PA etc and synchornized all the cores.

while (1) {

   // block till received semaphore signal

   read packets received in this 10ms period

   process packets

}

In a 10ms ISR I can post a semaphore. Now to generate the 10ms interrupt I want to make use of the unchained low or high timer counter to generate a call to the the ISR every 10ms. I had a look at the code  in pdk_c6678_1_0_0_19\packages\ti\csl\example\timer\timer_test.c and tried bringing in the appropriate code into my multicoreExample project and tried compling it but it complained about undefined symbols to do with the intc module during linking. The timer_test.c example code makes use of the intc and timer CSL modules so I have included the appropriate .h includes and I do not have any link errors does to the tmr CSL module but just the intc related modules.

Any ideas?

Thanks, Aamir

  • Hi,

    What PDK library you link in the executable?  Have you already included both ti.csl.intc.ae66 and ti.csl.ae66 (ELF abi) from the libs directory of the PDK?

    Some CSL routines are inline, so don't requires additional library, but some other CSL routine are in the PDK libraries.

  • Hi Aamir,

    can you please post the exact error message? ( what symbols are undefined?)

    Thanks,

  • Faraday,

    Please find the attached lof from the attempted build

    Thanks, Aamir

    ------------------------

    **** Build of configuration Debug for project PA_multicoreExample_exampleProject ****

    C:\Program Files\Texas Instruments\ccsv5\ccsv5\utils\bin\gmake -k all

    'Building file: C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c'

    'Invoking: C6000 Compiler'

    "C:/Program Files/Texas Instruments/ccsv5/ccsv5/tools/compiler/c6000/bin/cl6x" -mv64+ -g --include_path="C:/Program Files/Texas Instruments/ccsv5/ccsv5/tools/compiler/c6000/include" --include_path="C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/exampleProjects/PA_multicoreExample_exampleProject/../../../.." --include_path="C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/exampleProjects/PA_multicoreExample_exampleProject/../../../../ti/drv/pa/example/multicoreExample" --include_path="C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/exampleProjects/PA_multicoreExample_exampleProject/../../../../ti/drv/cppi" --include_path="C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/exampleProjects/PA_multicoreExample_exampleProject/../../../../ti/drv/qmss" --display_error_number --diag_warning=225 --mem_model:data=far --abi=eabi --preproc_with_compile --preproc_dependency="multicore_example.pp" --cmd_file="./configPkg/compiler.opt" "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c"

    "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c", line 219: warning #225-D: function declared implicitly

    "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c", line 647: warning #112-D: statement is unreachable

    "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c", line 688: warning #112-D: statement is unreachable

    "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c", line 373: warning #179-D: variable "i" was declared but never referenced

    "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c", line 375: warning #552-D: variable "rxStatus" was set but never used

    "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c", line 381: warning #179-D: variable "ucCurProcLoad" was declared but never referenced

    "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c", line 384: warning #179-D: variable "uiBegin" was declared but never referenced

    "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c", line 385: warning #179-D: variable "uiEnd" was declared but never referenced

    "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c", line 386: warning #179-D: variable "uiTicksPerSlot" was declared but never referenced

    'Finished building: C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_example.c'

    ' '

    'Building target: PA_multicoreExample_exampleProject.out'

    'Invoking: C6000 Linker'

    "C:/Program Files/Texas Instruments/ccsv5/ccsv5/tools/compiler/c6000/bin/cl6x" -mv64+ -g --display_error_number --diag_warning=225 --mem_model:data=far --abi=eabi -z -m"PA_multicoreExample_exampleProject.map" --warn_sections -i"C:/Program Files/Texas Instruments/ccsv5/ccsv5/tools/compiler/c6000/lib" -i"C:/Program Files/Texas Instruments/ccsv5/ccsv5/tools/compiler/c6000/include" --reread_libs --rom_model -o "PA_multicoreExample_exampleProject.out" -l"./configPkg/linker.cmd" "./qmss_device.obj" "./pam_bin.obj" "./pa_mgmt.obj" "./multicore_osal.obj" "./multicore_example.obj" "./cpsw_mgmt.obj" "./cppi_qmss_mgmt.obj" "./cppi_device.obj" "./classify2_bin.obj" "./classify1_bin.obj" -l"libc.a" "C:/Program Files/Texas Instruments/pdk_C6678_1_0_0_19/packages/ti/drv/pa/example/multicoreExample/multicore_linker.cmd"

    <Linking>

    undefined first referenced

    symbol in file

    --------- ----------------

    CSL_intcClose ./multicore_example.obj

    CSL_intcGlobalEnable ./multicore_example.obj

    CSL_intcGlobalNmiEnable ./multicore_example.obj

    CSL_intcHwControl ./multicore_example.obj

    CSL_intcInit ./multicore_example.obj

    CSL_intcOpen ./multicore_example.obj

    CSL_intcPlugEventHandler ./multicore_example.obj

    error #10234-D: unresolved symbols remain

    error #10010: errors encountered during linking;

    "PA_multicoreExample_exampleProject.out" not built

    >> Compilation failure

    gmake: *** [PA_multicoreExample_exampleProject.out] Error 1

    gmake: Target `all' not remade because of errors.

    **** Build Finished ****

  • Alberto,

    I am using PDK_c6678_1_0_0_19. I believe you are correct as I did not link any intc library and I read somewhere that the intc is not part of the actual CSL library. I am not sure where to add the ti.csl.intc.ae66 library in the PDK multicore example project. In the lib directory you mention, the ti.csl.ae66 must be included somehow in the project file as it does not complain about the other CSL functions like the CSL_tmr module.

    Thanks, Aamir

  • Hi Aamir,

    You can just add that library to the linker options. Please let me know if it works.

  • Select Project- >properties-> C600 Linker -> file search path and add the library name and also the path.

    Thanks.

  • Faraday,

    I figured it out. Basically the intc library is not included as part of the runtime load of the CSL package in the multicore_example.cfg file by default as it is expected that INTC support is part of BIOS normally. I read that on the INTC introduction within the compiled CSL help under \ti\csl\docs in tke PDK subdirectory.

    I had to add cslSettings module in xdc.useModule and then set useCSLIntcLib = true in the above named cfg file and then recompile.

    Is there any simple document etc that kind of summarises how the project load runtime packages and also how these packages are built etc in xdc? I am not really familiar with all of that and it involves a lot of guessing how things really work to get simple stuff like compiling code rather than spending the effort on the capability of the chip and actually trying out stuff.

    I also want to produce a makefile for compiling and linking and producing my .out file instead of making use of project files within CCS. Is there any documentation to help in that regards. I can then go about adding our proprietary code somewhat more easily rather than including it within the project.

    Thanks, Aamir

  • Aamir,

    You can look at the compiler user guide http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=spru187

    where it lists the steps and options that you can use for compiling and linking.

    I am looking around for answers to your run time related questions.

  • Faraday,

    Thanks for the link.

    I tried playing around with the measurements in the timer by making use of the TSCL so I would print out the TSCL just after I setup the timer and start it and then after the timerISRCounter is incremented after the ISR call on the timer going off. I set up the value of the PRDHI i.e. period register high to be 10,000,000 which should signify 10,000,000 cycles (10ms on a 1GHZ processor - which is what I assume the c6678 emv is running at). I actually ran some code that delayed by a 1000,000,000 ticks i.e. 1 second 60 times and it seems to match.

    Can you explain that?

    Alberto, I see you had some issues with the PRD register settings too in another post on this forum. Have you got any insight?

    Thanks, Aamir

  • Faraday,

    I forgot to complete my thought in my last email - Apologies.

    When making the measurements of TSCL before and after the timerISRCounter is incremented, I found the count had incremented by about 27,000,000 when I had set the period register to be 10,000,000.

    Thanks, Aamir

  • Aamir Husain said:

    Alberto, I see you had some issues with the PRD register settings too in another post on this forum. Have you got any insight?

    I solve the problem, there was a stupid mistake in my calculation. You have to keep in count the fixed internal CPU clock division applied by the timer, that is the value in EMUMGT_CLKSPD register:

      unsigned long clock = ((hTMR.EMUMGT_CLKSPD) >> 16) & 0x0F;
     double frq=1000000000.0/(double)clock;
     double v=(((double)period_ms)*0.001)*frq;
     unsigned long period=(unsigned long)v; // value to load in PRD reg.

    This works with the default timer configuration at the CPU reset.

  • thanks for the answer Alberto.

    Aamir, did that answer your question?

    Thanks and Regards,

    Kishore.

  • Alberto,

    Thanks for your email. Yes, I realized the internal clock division was a factor of 6 from reading through some documentation but thanks for your code example.

    Even with that I cannot completely reconcile the behaviour of the timer by making use of the TSCL count. From my understanding of the timer based on the timer_clock document on the TI online training website, it goes off the initial high timer count and then subsequently goes off after every PRDHI setting ticks. For my test I would like the timer to go off after 10ms on a 1GHZ processor which is 0.01*1000,000,000/6 so I set the PRDHI to be 1666667. I did that and I printed the TSCL prior to starting the timer with CSL_tmrHwControl and again after the timerISRCounter is no longer zero which would happen after the TimerInterruptHandler is called at least once, and I find that the TSCL has incremented by approx. 10,000,000 ticks which corresponds to 10ms as expected and the timerISRCounter has only incremented by 1 which would imply that the interrupt function is called once. (would this be the initial timeout as shown in BIOS user guide spruex3j pg 5-4 and does the PRDHI setting refer to both the intial timer and the subsequent periodic timers?).

    Anyways after I print out the TSCL a second time, I exit from my setup of the timer function without  disabling the interrupt event, stopping the timer, or closing the tmr and interrupt handlers as I want the timer to continue running and the interrupt going off every 10ms and calling the ISR. I then start an infinite while loop

    While (1) {

    Print the timerISRCounter and the TSCL

    Run some small code to see if any packets received from PA (should just take minimal cycles)

    }

    I would expect that the TSCL increments by a small amount and the timerISRCounter should not increment by anything till the cumulative TSCL has incremented by 10,000,000 but what I am seeing is that the TSCL is incrementing by a small amount but the timerISRCounter is incrementing by one every time around the loop which would mean the ISR is getting called and the interrupt is going off in a lot less than 10,000,000 ticks as measured by TSCL.

    Any insights on this?

    Thanks, Aamir

  • Kishore, Alberto,

    Here is a sample timer setup code and the result of printing out

    /**  
     * @file multicore_example.c
     *
     * @brief 
     *  Example to illustrate the usage of EMAC CPSW3G switch using CPPI, QMSS
     * 	low level drivers and CSL.
     *
     * 	This example application does the following:
     * 	    (1) Initializes:
     * 	            (a) Queue Manager (QM) Subsystem 
     * 	            (b) Packet Accelerator (PA) CPPI DMA 
     * 	            (c) Ethernet Subsystem (Ethernet switch + SGMII + MDIO)
     * 	            (d) PA Subsystem + PDSP
     *
     * 	    (2) Sets up the CPPI descriptors and Queues required for sending and
     * 	        receiving data using Ethernet.
     * 	            (a) Uses Host descriptors
     * 	            (b) Uses High Priority Accumulation interrupts
     *
     * 	    (3) Sets up the example application's configuration (MAC address
     * 	        it uses to send/recv data; IP address and port number it's listening
     * 	        on) in PA Subsystem so as to enable the PASS to forward all packets
     * 	        matching this configuration onto the application for processing.
     * 	            (a) Switch MAC address configured   =   0x10:0x11:0x12:0x13:0x14:0x15
     * 	            (b) Example's IP address            =   192.168.1.10
     * 	            (c) Example App's listening port    =   0x5678
     *
     * 	    (4) Sends packets onto wire 
     * 	        (constructed manually in code here with following settings):
     * 	            (a) Source MAC      =   0x00:0x01:0x02:0x03:0x04:0x05
     * 	                Destination MAC =   0x10:0x11:0x12:0x13:0x14:0x15
     *              (b) Source IP       =   192.168.1.1
     *                  Destination IP  =   192.168.1.10
     *              (c) Source Port     =   0x1234
     *                  Destination Port=   0x5678
     *              (d) Payload Data (80 bytes)
     *
     *          The packets sent by the application are sent onto wire and 
     *          since the destination MAC on the packet is the Ethernet Switch 
     *          MAC address, the packets are received by simulator and passed 
     *          back up to the example application for processing.
     *      
     *      (5) Application receives all packets using QM High priority interrupt
     *          registered; Validates received packet against data sent.
     *
     *  Example application Setup:
     *
     *          PC Running Simulator using CCS connected to a
     *          Switch/Hub. You could put another PC on the Hub to observe packets 
     *          being sent onto wire. 
     *
     *          Please consult the Readme.txt packaged with the example to 
     *          setup the CCS simulator configuration required to run this example 
     *          succesfully.
     *
     *  \par
     *  ============================================================================
     *  @n   (C) Copyright 2009, Texas Instruments, Inc.
     * 
     *  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 <multicore_example.h>
    #include <ti/csl/cslr_device.h>
    #include <ti/csl/csl_psc.h>
    #include <ti/csl/csl_pscAux.h>
    #include <ti/csl/csl_tmr.h>
    #include <ti/csl/csl_tmrAux.h>
    #include <ti/csl/src/intc/csl_intc.h>
    #include <ti/csl/src/intc/csl_intcAux.h>
    
    /* PA LLD include */
    #include <ti/drv/pa/pa.h>
    
    
    /**************************************************************
    ************************** DEFINITIONS ************************
    ***************************************************************/
    /* Number of packets to be used for testing the example. */
    #define                     MAX_NUM_PACKETS                         10u
    
    
    /**************************************************************
    ************************* GLOBAL VARIABLES ********************
    ***************************************************************/
    /* Counters to track number of packets sent/received by this application */
    extern volatile UInt32		 gRxCounter, gTxCounter, gSavedRxCounter;
    
    /*
     * Default test configuration for the silicon
     *
     * To run test at the CCS simulator
     *    cpswSimTest = 1
     *    cpswLpbkMode = CPSW_LOOPBACK_EXTERNAL
     */
    #ifdef  SIMULATOR_SUPPORT
    Int cpswSimTest = 1;
    Int cpswLpbkMode = CPSW_LOOPBACK_EXTERNAL;
    #else
    Int cpswSimTest = 0;
    //Int cpswLpbkMode = CPSW_LOOPBACK_INTERNAL;
    Int cpswLpbkMode = CPSW_LOOPBACK_NONE;
    #endif
    Int cpswEvm6678 = 1;
    
    /* multicore sync up variables */
    #pragma DATA_ALIGN   (globalCfgDone, 128)
    #pragma DATA_SECTION(globalCfgDone,   ".sharedDDR")
    volatile UInt32  globalCfgDone = FALSE;   
    
    #pragma DATA_ALIGN   (localCfgDone, 128)
    #pragma DATA_SECTION(localCfgDone,    ".sharedDDR")
    /* number of local configuration completed */
    volatile UInt32  localCfgDone = 0;        
    
    #pragma DATA_ALIGN   (readyToSendPkts, 128)
    #pragma DATA_SECTION(readyToSendPkts, ".sharedDDR")
    volatile UInt32  readyToSendPkts = FALSE;      
    
    /**************************************************************
    **************** EXAMPLE APP FUNCTIONS ************************
    ***************************************************************/
    
    /* INTC Objects */
    CSL_IntcObj                  tmrIntcObj;
    CSL_IntcContext              context;
    CSL_IntcEventHandlerRecord   EventHandler[30];
    
    /* Global Variable for the INTC Module; useful for debugging. */
    CSL_IntcRegsOvly    gIntcRegisters    = (CSL_IntcRegsOvly)CSL_CGEM0_5_REG_BASE_ADDRESS_REGS;
    
    /* Counter for Timer ISR */
    volatile Int32 timerISRCounter = 0;
    
    /**
     *  @b Description
     *  @n
     *      This is the Timer ISR handler which is invoked when the timer expires
     *
     *  @param[in]  arg
     *      Event ID which caused the ISR to be invoked.
     *
     *  @retval
     *      Not Applicable.
     */
    static void TimerTick (void *arg)
    {
        /* Increment the number of interrupts detected. */
        timerISRCounter++;
    
        /* Clear the event ID. */
        CSL_intcEventClear((CSL_IntcEventId)arg);
    }
    
    /**
     *  @b Description
     *  @n
     *      This function is used to setup the HI Timer in Continuous Mode
     *
     *  @param[in]  IntcInstance
     *      Timer Instance Number
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static Int32 setup_high_continuous_timer (Uint8 IntcInstance)
    {
        CSL_TmrHandle               hTmr;
        CSL_TmrObj                  TmrObj;
        CSL_Status                  status;
        CSL_TmrHwSetup              hwSetup = CSL_TMR_HWSETUP_DEFAULTS;
        CSL_IntcEventHandlerRecord  EventRecord;
        CSL_IntcParam               vectId;
        CSL_IntcHandle              tmrIntcHandle;
        Uint32                      LoadValue = 1666667;
        Uint32                      LoadCntValue = 0;
        CSL_TmrEnamode              TimeCountMode = CSL_TMR_ENAMODE_CONT;
        Uint32                      count;
    	int i;
    
        /* Clear local data structures */
        memset(&TmrObj, 0, sizeof(CSL_TmrObj));
        System_printf("Debug: Setup High Timer (Unchained) in Continuous Mode....\n");
    
        /**************************************************************
         ********************** INTC related code *********************
         **************************************************************/
    
        /* Open INTC */
        vectId = CSL_INTC_VECTID_13;
        tmrIntcHandle = CSL_intcOpen(&tmrIntcObj, CSL_GEM_TINTHN, &vectId, NULL);
        if (tmrIntcHandle == NULL)
            return -1;
    
        /* Bind ISR to Interrupt */
        EventRecord.handler = (CSL_IntcEventHandler)&TimerTick;
        EventRecord.arg     = (void *)CSL_GEM_TINTLN;
        CSL_intcPlugEventHandler(tmrIntcHandle, &EventRecord);
    
        /* Event Enable */
        CSL_intcHwControl(tmrIntcHandle, CSL_INTC_CMD_EVTENABLE, NULL);
    
        /**************************************************************
         ********************** Timer related code ********************
         **************************************************************/
    
        /* Open the timer. */
        hTmr =  CSL_tmrOpen(&TmrObj, IntcInstance, NULL, &status);
        if (hTmr == NULL)
            return -1;
    
        /* Open the timer with the defaults. */
        CSL_tmrHwSetup(hTmr, &hwSetup);
    
        /* Stop the Timer */
        CSL_tmrHwControl(hTmr, CSL_TMR_CMD_RESET_TIMHI, NULL);
    
        /* Set the timer mode to unchained dual mode */
        hwSetup.tmrTimerMode = CSL_TMR_TIMMODE_DUAL_UNCHAINED;
        CSL_tmrHwSetup(hTmr, &hwSetup);
    
        /* Reset the timer ISR Counter. */
        //timerISRCounter = 0;
    
        /* Load the period register */
        status = CSL_tmrHwControl(hTmr, CSL_TMR_CMD_LOAD_PRDHI, (void *)&LoadValue);
    
        /* Load the initial count register */
        //status = CSL_tmrHwControl(hTmr, CSL_TMR_CMD_LOAD_PSCHI, (void *)&LoadCntValue);
    
    	System_printf("TSCL=%d timerCntr=%d\n",TSCL,timerISRCounter);
        /* Start the timer in CONTINUOUS Mode. */
        CSL_tmrHwControl(hTmr, CSL_TMR_CMD_START_TIMHI, (void *)&TimeCountMode);
    
    	while (1)
    	{
    		// Block here until receiving a semaphore signal to signal a 10ms cycle time
    		CycleDelay(10000000);
    		System_printf("TSCL=%d timerCntr=%d\n",TSCL,timerISRCounter);
    	}
    
        /* Wait for the timer interrupts to fire...*/
        while (timerISRCounter <= 0);
    	System_printf("TSCL=%d timerCntr=%d\n",TSCL,timerISRCounter);
        timerISRCounter = 0;
    
        /* Since the HIGH Counter is operating in Continuous Mode; the value here should
         * be non-zero. Though there is a small probability that the value here could be 0. */
        //CSL_tmrGetTimHiCount(hTmr, &count);
        //if (count == 0)
        //{
            /* Taking into account the small probability; lets confirm out again.
             * This time for sure the value should be non-zero. */
        //    CSL_tmrGetTimHiCount(hTmr, &count);
        //    if (count == 0)
        //        return -1;
        //}
    
        /**************************************************************/
    
        /* Disable the events. */
        //CSL_intcHwControl(tmrIntcHandle, CSL_INTC_CMD_EVTDISABLE, NULL);
    
        /* Stop the Timer */
        //CSL_tmrHwControl(hTmr, CSL_TMR_CMD_RESET_TIMHI, NULL);
    
        /* Close the Tmr and Interrupt handles. */
        //CSL_tmrClose(hTmr);
        //CSL_intcClose(tmrIntcHandle);
    
    	while(1)
    	{
    		// Block here until receiving a semaphore signal to signal a 10ms cycle time
    		System_printf("TSCL=%d timerCntr=%d\n",TSCL,timerISRCounter);
    		//CycleDelay(5000000);
    	}
    
        /* Test has completed successfully. */
        return 0;
    }
    
    /***************************************************************************************
     * FUNCTION PURPOSE: Power up PA subsystem
     ***************************************************************************************
     * DESCRIPTION: this function powers up the PA subsystem domains
     ***************************************************************************************/
    void passPowerUp (void)
    {
    
        /* PASS power domain is turned OFF by default. It needs to be turned on before doing any 
         * PASS device register access. This not required for the simulator. */
    
        /* Set PASS Power domain to ON */        
        CSL_PSC_enablePowerDomain (CSL_PSC_PD_PASS);
    
        /* Enable the clocks for PASS modules */
        CSL_PSC_setModuleNextState (CSL_PSC_LPSC_PKTPROC, PSC_MODSTATE_ENABLE);
        CSL_PSC_setModuleNextState (CSL_PSC_LPSC_CPGMAC,  PSC_MODSTATE_ENABLE);
        CSL_PSC_setModuleNextState (CSL_PSC_LPSC_Crypto,  PSC_MODSTATE_ENABLE);
    
        /* Start the state transition */
        CSL_PSC_startStateTransition (CSL_PSC_PD_PASS);
    
        /* Wait until the state transition process is completed. */
        while (!CSL_PSC_isStateTransitionDone (CSL_PSC_PD_PASS));
    }
    
    /**
     *  @b Description
     *  @n
     *      The functions initializes the INTC module.
     *
     *  @retval
     *      Success -   0
     *  @retval
     *      Error   -   <0
     */
    static Int32 intc_init (void)
    {
        CSL_IntcGlobalEnableState   state;
    
        /* INTC module initialization */
        context.eventhandlerRecord = EventHandler;
        context.numEvtEntries      = 100;
        if (CSL_intcInit(&context) != CSL_SOK)
            return -1;
    
        /* Enable NMIs */
        if (CSL_intcGlobalNmiEnable() != CSL_SOK)
            return -1;
    
        /* Enable global interrupts */
        if (CSL_intcGlobalEnable(&state) != CSL_SOK)
            return -1;
    
        /* INTC has been initialized successfully. */
        return 0;
    }
    
    /** ============================================================================
     *   @n@b MultiCoreApp
     *
     *   @b Description
     *   @n Example application that sets up the application, sends, receives
     *      data.
     *
     *   @param[in]  
     *   @n None
     * 
     *   @return
     *   @n None
     *
     * =============================================================================
     */
    Void MultiCoreApp (Void)
    {
    	Int32	   i;
      	UInt32     coreNum;
    	Int32	   rxStatus=0;
    
        /* Get the core number. */
        coreNum = CSL_chipReadReg(CSL_CHIP_DNUM); 
    
    
        System_printf ("************************************************\n");
        System_printf ("*** MS Started on Core %d ***\n",coreNum);
        System_printf ("************************************************\n");
    
        /* Init internal cycle counter */
        TSCL = 1; 
        
        /* Disable L1 and L2 Cache */
        //CACHE_wbAllL1d (CACHE_WAIT);
        //CACHE_setL1DSize(CACHE_L1_0KCACHE);
        //CACHE_setL1PSize(CACHE_L1_0KCACHE);
        #ifndef L2_CACHE
        CACHE_setL2Size(CACHE_0KCACHE);
        #endif
        
        /* All other cores wait for core 0 to finish the global config
           and setup the QMSS/CPPI/PASS */
        if(coreNum)
        {
            System_printf ("Waiting for global config...\n");
            while(!globalCfgDone)
                SYS_CACHE_INV ((void *) &globalCfgDone, 128, CACHE_WAIT);
        }
        
        /* Core 0 does the global initialization */
        if(!coreNum)
        {
            /* Enable PASS power domain */
            passPowerUp();        
            
            /* Initialize the components required to run the example:
             *  (1) QMSS
             *  (2) CPPI
             *  (3) Ethernet switch subsystem + MDIO + SGMII
             */
            /* Initialize QMSS */
            if (Init_Qmss () != 0)
            {
                System_printf ("QMSS Global init failed \n");
                BIOS_exit (-1);
            }
            else
            {
                System_printf ("QMSS successfully initialized \n");            
            }
    
            /* Initialize CPPI */
            if (Init_Cppi () != 0)
            {
                System_printf ("CPPI init failed \n");
                BIOS_exit (-1);
            }
            else
            {
                System_printf ("CPPI successfully initialized \n");            
            }
    
            /* Init PA LLD */
            if (Init_PASS () != 0)
            {
                System_printf ("PASS init failed \n");
                BIOS_exit (-1);
            }
            else
            {
                System_printf ("PASS successfully initialized \n");            
            }
    
            /* Initialize the CPSW switch */
            if (Init_Cpsw () != 0)
            {
                System_printf ("Ethernet subsystem init failed \n");
                BIOS_exit (-1);
            }
            else
            {
                System_printf ("Ethernet subsystem successfully initialized \n");            
            }
    
            /* Setup Tx */
            if (Setup_Tx () != 0)
            {
                System_printf ("Tx setup failed \n");
                BIOS_exit (-1);
            }
            else
            {
                System_printf ("Tx setup successfully done \n");            
            }
        }
        else
        {
            SYS_CACHE_INV ((void *) &gGlobalFreeQHnd, 128, CACHE_WAIT);
            /* Cores other than 0 do local QMSS initialization */
            if (Init_Qmss_Local () != 0)
            {
                System_printf ("QMSS Local init failed \n");
                BIOS_exit (-1);
            }
            else
            {
                System_printf ("QMSS Local successfully initialized \n");            
            }
            
            /* 
             * read the actual value from memory which have been initialized by core 0
             */
            //SYS_CACHE_INV ((void *) &gRxFreeQHnd, 128, CACHE_WAIT);
            SYS_CACHE_INV ((void *) &gTxFreeQHnd, 128, CACHE_WAIT);
            SYS_CACHE_INV ((void *) gPaTxQHnd, 128, CACHE_WAIT);
            SYS_CACHE_INV ((void *) gPaL3Handles, 128, CACHE_WAIT);
            SYS_CACHE_INV ((void *) &gPAInstHnd, 128, CACHE_WAIT);
        }    
    
        /* Setup Rx */
        if (Setup_Rx () != 0)
        {
            System_printf ("Rx setup failed \n");
            BIOS_exit (-1);
        }
        else
        {
            System_printf ("Rx setup successfully done \n");            
        }
    
        /* Setup PA */
        if (Setup_PASS () != 0)
        {
            System_printf ("PASS setup failed \n");
            BIOS_exit (-1);
            
        }
        else
        {
            System_printf ("PASS setup successfully done \n");            
        }
    
        /* Core 0 finished the global config. Set flag so other
           cores can start their local config. */
        if (!coreNum)
        {
          globalCfgDone=TRUE;
          SYS_CACHE_WB ((void *) &globalCfgDone, 128, CACHE_WAIT);
    
        }  
        
        /* All cores update the counter informing that they finished their setup */
        /* The global variable is a shared resource which is being accessed from multiple cores. 
         * So here we need to protect it and ensure that there is only 1 core which is accessing 
         * it at a time. We use a Hardware Semaphore to protect this. */
        while ((CSL_semAcquireDirect (PA_APP_HW_SEM_SYS)) == 0);
    
        /* Invalidate the cache and make sure you get the latest from the memory. */
        SYS_CACHE_INV ((void *) &localCfgDone, 128, CACHE_WAIT);
    
        /* The core has completed local initialization */
        localCfgDone++;
    
        /* The SRIO Socket has been created. Writeback the contents to the cache. */
        SYS_CACHE_WB ((void *) &localCfgDone, 128, CACHE_WAIT);
    
        /* Release the hardware semaphore. */
        CSL_semReleaseSemaphore (PA_APP_HW_SEM_SYS);
        
        /* All cores wait here to sync up and send packets to PA
           at the same time. */
        System_printf ("Waiting for all cores to reach the barrier before transmission starts ... \n");
        
        while (localCfgDone != NUM_CORES)
            SYS_CACHE_INV ((void *) &localCfgDone, 128, CACHE_WAIT);
        
        /*if (!coreNum)
    	{
    	    if (!cpswSimTest)
    	    {
    	        System_printf("Following is the ALE table before transmits or receives.\n");
    	        view_ale_table();	// Added by Atsushi
    	    }
    	}*/
    
        System_printf("core %d can start receiving and sending\n", coreNum);
    
        /* Initialize the INTC Module. */
        if (intc_init() < 0)
        {
            System_printf ("Error: Initialization of the INTC module failed\n");
            return;
        }
    
        /* Initialize timer CSL module */
        CSL_tmrInit(NULL);
    
        /* Setup the High Timer in Continuous Mode. */
        if (setup_high_continuous_timer(CSL_TMR_0) < 0)
        {
            System_printf("Error: Setup High Timer (Unchained) in Continuous Mode FAILED\n");
            return;
        }
        //System_printf("Debug: Setup High Timer (Unchained) in Continuous Mode Passed\n");
    
        // Main task infinite loop
    	while(1)
    	{
    		// Block here until receiving a semaphore signal to signal a 10ms cycle time
    		System_printf("TSCL=%d timerCntr=%d\n",TSCL,timerISRCounter);
    		//CycleDelay(5000000);
    
    	    // Read, retrieve and parse incoming packet one by one until no data to read
    	    while (1)
    	    {
    	        if(ReceivePacket() != 0)
    	            rxStatus=-1;
    	        while (gSavedRxCounter != gRxCounter)
    	        {
    	        	gSavedRxCounter = gRxCounter;
    	        	System_printf("core %d Received %d packets so far... %d\n", coreNum, gRxCounter, gSavedRxCounter);
    				CycleDelay (10000);
    				/*if (!cpswSimTest)
    				{
    					if (++ ct_show_ale >= 10) {
    						view_ale_table();
    						ct_show_ale = 0;
    					}
    				}*/
    	        }
    
    			// If no more data to read 
    			if (rxStatus == -1)
    			{
    				break;
    			}
    	    }
        }
    
        System_printf ("**********************************************\n");
        System_printf ("*** MS Ended on Core %d ***\n",coreNum);
        System_printf ("**********************************************\n");
    
        /* Example application done. Return success */
        BIOS_exit (0);
    }
    
    /** ============================================================================
     *   @n@b main
     *
     *   @b Description
     *   @n Entry point for single core example application.
     *
     *   @param[in]  
     *   @n None
     * 
     *   @return
     *   @n None
     * =============================================================================
     */
    Int32 main (Void)
    {
        Task_Params                	cpswTaskParams;
        
        /* Initialize the task params */
        Task_Params_init(&cpswTaskParams);
    
        /* Create the CPSW single core example task */
        Task_create((Task_FuncPtr)&MultiCoreApp, &cpswTaskParams, NULL);
    
        /* Start the BIOS Task scheduler */
    	BIOS_start ();
    
    	return 0;	
    }
    

    the TSCL counts below do nto make sense if i comment out the infinite while loop after starting the timer then the count increments correctly by 1 after 10,000,000 clocks ticks but otherwise not.

    [C66xx_0] ************************************************

    [C66xx_0] *** MS Started on Core 0 ***

    [C66xx_0] ************************************************

    [C66xx_0] Initializing Free Descriptors.

    [C66xx_0] QMSS successfully initialized

    [C66xx_0] CPPI successfully initialized

    [C66xx_0] PASS successfully initialized

    [C66xx_0] Ethernet subsystem successfully initialized

    [C66xx_0] Tx Free descriptor queue = 736

    [C66xx_0] Tx setup successfully done

    [C66xx_0] Rx Free command descriptor queue = 737

    [C66xx_0] Rx Free ethernet descriptor queue = 745

    [C66xx_0] Rx Free command descriptor queue = 737

    [C66xx_0] Rx Free ethernet descriptor queue = 745

    [C66xx_0] Rx setup successfully done

    [C66xx_0] PASS setup successfully done

    [C66xx_0] Waiting for all cores to reach the barrier before transmission starts ...

    [C66xx_0] core 0 can start receiving and sending

    [C66xx_0] Debug: Setup High Timer (Unchained) in Continuous Mode....

    [C66xx_0] TSCL=6596233 timerCntr=0

    [C66xx_0] TSCL=16604517 timerCntr=0

    [C66xx_0] TSCL=26613147 timerCntr=3

    [C66xx_0] TSCL=36621567 timerCntr=5

    [C66xx_0] TSCL=46629989 timerCntr=7

    [C66xx_0] TSCL=56638417 timerCntr=9

    [C66xx_0] TSCL=66646846 timerCntr=11

    [C66xx_0] TSCL=76655569 timerCntr=13

     

  • Hi,

    Just an idea (maybe wrong): Your monitoring method could be intrusive. The System_printf() is implemented by a break point captured by the JTAG debugger. The CPU is stopped the time required to read your C I/O buffer. The TCSL stop also, so the TCSL counter seem to be coherent, but I'm not sure what append to the timer (there is an option to sync it with the emulator, but I have never check it).  Collect some stat in a buffer and look at it after some cycles.

  • Alberto,

    Thanks for your advice. You were correct. My monitoring was intrusive. I saved my TSCL and timerISRCounter to separate buffers and viewed them after a 100 runs through the loop for certain delays during each iteration of the loop and the ISR counters are now matching the expected values based on the TSCL cnt. I tried this for several delays and it always made sense.

    So it seems that the timer is not synced. I will look into this issue. Any advice from the TI folks here.

    thanks, Aamir

  • Looking through the spruex3j sysbios user guide page 7-2, it suggests to avoid using CSL interrupt, timer functions and SYS/BIOS in the same application, since this combination is known to result in complex interrupt related debugging problems. I suspect maybe if I make use of the timer within the BIOS instead, I may be able to have the synchronization that I desire.

    Any comments?

    THanks, Aamir

  • I am seeeing that after i introduce the function intc_init which initializes the INTC module into my code (This step is done after the configuration is complete on all cores and each core is ready to receive or send packets through the PA/switch), I am finding that the ReceivePacket function which is supposed to check the Rx Queue for each core through the Qmss_getQueueEntryCount (gRxQHnd[coreNum]) function to see if there are any packets received by the PA is getting triggered even though I am not yet sending any ethernet UDP packets to the DSP. If I am to comment out the initc initialization my receive module starts to work again.

    Any help would be appreciated in figuring this out.

    Aamir

  • Aamir,

    1) Are you sending packets from one core and trying to receive/process them on other core?

    2) So, you are saying even though you do not push any packets to PA TX Q's, you are receiving packets in the RXQ which is monitored on the other core?

    Thanks,

    Kishore.

  • Kishore,

    I am sending packets from outside the c6678 DSP to a core on the DSP.  In this particular example I just have code running on core 0 so the packets are being sent to core 0.

    Yes, I am obviously receiving some packet on the Rx queue for core 0 as the QMSs handle returns a non-zero value indicating descriptors in the queue although when I pop the descriptor it is null i.e. hd is null below.

    hd = (Cppi_Desc *)(((UInt32)Qmss_queuePop (gRxQHnd[coreNum])) & ~0xf);

    Thanks, Aamir

  • Aamir,

    it would be helpful, if you could pls post the updated code.

    Thanks,

    Kishore.

  • Kishore,

    I solved the issue last week on why the packet queue was seeing this errant packet even though I was not sending anything. It turned out I was calling the init function for the intc after the PA setup etc. When I moved the init function to prior to the PA and RX, TX queues etc, it worked fine.

    I also resolved the basic issue of getting a 10ms timer to go off, call an ISR and give control back to my main task which was waiting for a signal (semaphore pend or global variable) to indicate that it can continue processing so I have a 10ms processing cycle working know for receiving packets. Basically  I found that if I did the system reset in the debug perspective, I needed to run the global default setup under scripts->EVMc6678 init functions to get it working properly. When I did not run that, the code seemed to work except for the fact that the TSCL timing was not consistent with the actual time and was slower by a factor of 10 so 5 seconds of time using the TSCL counter would correspond to 50 secs of real time. We were making use of the derivative of printf, more like a sprintf in our earlier product and though it takes a lot of time, we do use it for debug purposes to debug our code when problems occur and were able to run it every 10ms so it was able to take a less than 10ms to run to completion without negatively impacting the behaviour as long as the desired code was not taking close to 10ms of processing time.

    Thanks though for your note.

    Aamir

  • Aamir,

    Glad to know, you found the answer.

  • Hello TI Folks,

    I am replying on this thread as I was away from this project for a few months and have restarted looking again at the issue of having a application loaded on multiple cores with each core waking up every 10ms to begin some processing. When I was last looking at this in early June I was able to get my timer interrrupt code working for a single core were I would initialize the INTC module then the timer CSL module then initialize and setup the QMSS, CPPI, switch and PASs subsystems and setup the TX and RX setup for sending and receving data to/from PASS. I finally then setup a high timer in continuous mode (unchained) and then began a main task infinite while loop in which I have a while(timerTickCount != 1); loop so when 10ms expires for a single core the timer ISR is called which set timerTickCount to 1 and so this while loop is exited and I reset timerTickCount=0 and the code can then begin to check for any received packets from the PA by calling a function ReceivePacket which is based on the TI multicore example. However, when I go to multiple cores and load the application on say two cores I am no longer able to get this 10ms interrupt to work. I had included my main multicore App example source code earlier in this thread. Do I need to have 8 of these timers setup for each core or can I have one timer go off and cause all 8 cores to wake up? Is the TSCL register shared by all the cores?  The setup_high_continuous_timer code is modelled on the timer code in the CSL directory within the PDK directory. Also once the timer is started, I exit the setup_high_continuous_timer function.

    Any help would be appreciated.

    Thanks, Aamir