• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Digital Signal Processors (DSP) » C6000 Multicore DSP » Keystone Multicore Forum (C66, 66A, AM5) » Issues to General Purpose 64 bit Timer
Share
C6000 Multicore DSP
  • Forums
  • Announcements
Options
  • Subscribe via RSS
Training Available
TI provides self-paced online training that introduces the primary components of the KeyStone II family of SoC devices.

  • KeyStone II SoC Overview >
  • KeyStone II Software Overview >
  • KeyStone II ARM Cortex-A15 Corepac Overview >
  • More Information >
  • Check out
    Multicore Mix blog
    • $core_v2_blog.Current.Name

      It’s our second anniversary, but you get the present!

      Posted 5 days ago
      by Lindsey Bare
      It’s hard to believe it’s already been two years...
    • $core_v2_blog.Current.Name

      Limited time offer: Save $100 on Keystone-based EVM!

      Posted 18 days ago
      by tscheck
      Have you been thinking about ordering a TI Keystone-based EVM...
    • $core_v2_blog.Current.Name

      Imagine the impact…TI’s KeyStone SoC + HP Moonshot

      Posted 29 days ago
      by Sanjay35057
      Last week, market leader Hewlett Packard announced a huge change...

    Forums

    Issues to General Purpose 64 bit Timer

    This question is answered
    Bernd Erbe
    Posted by Bernd Erbe
    on May 08 2012 01:03 AM
    Expert1330 points

    Hello,

    I've used the GP 64 Bit Timer for timing measurements and run into several problems. Having found these two threads (which are unfortunately not answered yet; http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/177732.aspx & http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/180641.aspx), I got the same problems.

    Device is a C6678, code example can be seen below (simple set up a timer, trigger an interrupt on Core 0 and measure time until IRQ is entered on Core 1). Testing this I run into following problems:

    1) starting the timer just after the reset, I only get a time stamp on the first read; I suppose (low value is very high) on the second read the timer has timed out allthough the period is set to maximum and the timer is set to continous.

    2) Starting the timer after open and called "Reset" before triggering the Interrupt just stops the timer and don't reset the counter. Moreover I always got a value in the Low-Register, the High is always 0. Why?

    3) To avoid the two problems above, I just start the timer before triggering the Interrupt. The I got the following values: Timer start at 88462901 (Core 0), Timer stop at 88462593 (Core 1). I thought this is timer with the same time stamp on each core. How can the stamp reaching the IRQ be less than the stamp before triggering the interrupt???

    4) Calculating the time: timer is running with 1/6 core frequency, which is 166.67 in my example (core runs with 1000 MHz). Cycle difference is 308 -> Time is Cycles / Clock => 308 / (166,67 x 10^6) = 1,85 / 10^6 = 1,85 micro seconds??? Such a long time for triggering a interrupt? Maybe there's something wrong in my calculation or the time stamps are wrong.

    Hope somebody can help me on this issues.
    Best Regards,
    Bernd

    --- Core 0 & 1---

        memset(&TmrObject, 0, sizeof(TmrObject));
        TmrHandle = CSL_tmrOpen(&TmrObject, 7, NULL, &CSLStatus);
        if(TmrHandle == NULL)
        {
            Log_print0(Diags_USER1, "Timer_setup failed");
            exitFailure(0);
        }

        TmrHwSetup.tmrTimerMode = CSL_TMR_TIMMODE_GPT;
        TmrHwSetup.tmrTimerPeriodLo = 0xffffffff;
        TmrHwSetup.tmrTimerPeriodHi = 0xffffffff;
        CSL_tmrHwSetup(TmrHandle, &TmrHwSetup);
        CSL_TmrReset64(TmrHandle);

    --- Core 0 ---

        CSL_tmrGetTimLoCount(TmrHandle, &uiCountLowStart);
        Log_print1(Diags_USER1, "Timer Low Start:  %d\n", uiCountLowStart);

        volatile uint32_t *uiptr_register = (uint32_t *) 0x02620240;
        uiptr_register += 1;
        *uiptr_register |= (1 << 4);     // set source
        *uiptr_register |= 1;            // interrupt

    --- Core 1 ---
    void IRQ_test(UArg arg)
    {
        if(DNUM == 1)
        {
            CSL_tmrGetTimLoCount(TmrHandle, &uiCountLowStop);
            Log_print1(Diags_USER1, "Timer Low Stop: %d\n", uiCountLowStop);
        }

    }

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • one and zero
      Posted by one and zero
      on May 08 2012 07:52 AM
      Expert6825 points
      Timed_interrupt.zip

      Hi Bernd,

      lot's of questions in one go. I attached a project measuring the cycles for an IPC interrupt. My counter reaches approx. 100. In cycle count that's 600 since the general purpose counters run at CPU/6.

      The time measured includes the time to get from the interrupt vector to the actual ISR. So it's not only the time it takes to trigger the interrupt but also run through the ISR dispatching.

      A couple of potential issues in your code. Only one core should configure the GP Timer. You need to synchronize the cores to make sure everything is initialized properly before you start to trigger the interrupt ...

      Kind regards,

      one and zero

       

      Please click the Verify Answer button on this post if it answers your question.

      You can also follow me on Twitter: http://twitter.com/oneandzeroTI

      Do you want to read interesting multicore articles? Check out our Multicore Mix

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Bernd Erbe
      Posted by Bernd Erbe
      on May 09 2012 02:02 AM
      Expert1330 points

      Hello one and zero,

      Sorry for misunderstanding due to the measured time; I meant the time which it lasts until the ISR is entered.

      Thanks for your example. I've tested it (I also got 100 cycles). Configure the timer only by one core changed the behaviour of my program so that I measure nearly 160 cycles (I think the other 60 cycles are due to some overhead for SYS/BIOS, SystemAnalyzer, ... I'm using at the moment). So point 1) to 3) are okay. But I'm not clear with point 4:

      Measuring 100 cycles are equivalent with 0,6 microseconds until the ISR entered (with 1000 MHz Core Clock Frequency)? This is a very long time isn't it? Are there any possibilities to speed up this time? I thought I've read about 200 ns instead of 600 ns...

      Best Regards,
      Bernd

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • one and zero
      Posted by one and zero
      on May 10 2012 02:58 AM
      Verified Answer
      Verified by Bernd Erbe
      Expert6825 points
      Timed_interrupt2 (2).zip

      Hi Bernd,

      yes you can be a bit faster. If you directly jump into your ISR from the Interrupt vector. That way you save the cycles going through the interrupt dispatching done in the CSL.

      I attached this version as Timed_interrupt2(2).zip (Includes 2 zip file with the 2 versions Timed_interrupt using CSL for interrupt handling and Timed_interrupt2 managing interrupts "manually").

      In addition also the CSL interrupt actually consumes less. I did a mistake in my first attempt. I corrected the storage of the time stamps. TI put them in Shared L2 so I can easily read and write from both cores. In my first version I read from local L2 so the start value printed out was always 0. The second change I did was adding a delay for core 0 to make sure core 1 is sitting in the while loop when core 0 triggers the interrupt.

      Now the timer deltas are:

      For CSL: about 80 -> 480 cycles

      No CSL: With optimizer turned on (release) I get 54 -> 324 cycles

      if I move the read of the timer right after the the line that triggers the interrupt the delta goes down to 16 - > 96 cycles. This seems OK looking at the assembly code generated.

      So it also depends a lot on the compiler what you actually see as latency ...

      If you write you ISR in assembly you can  save additional cycles. Because you are responsible to save the C context and can optimize depending on the register usage in your assembly routine ...

      Kind regards,

      one and zero

       

      Please click the Verify Answer button on this post if it answers your question.

      You can also follow me on Twitter: http://twitter.com/oneandzeroTI

      Do you want to read interesting multicore articles? Check out our Multicore Mix

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Philipp Schmidbauer
      Posted by Philipp Schmidbauer
      on Jan 30 2013 09:16 AM
      Intellectual310 points

      Hi...

      I tried the timed_interrupt example of one and zero and got it to work! But when I combined the example with my project, my HWIs don't work anymore.... is there any possibility, to get both (HWI and Inter processor interrupts) running in the same project? what have I to do?

      Thx for your help...

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Bernd Erbe
      Posted by Bernd Erbe
      on Jan 30 2013 23:48 PM
      Expert1330 points

      Hello Philipp,

      it depends what (if) your using a framework; e.g. if you're using Sys/Bios, it's no problem to use HWI's and IPC (is also only a HWI with an appropriate configuration). For an example see below. If this doesn't work, please provide a code example how you configure your IRQ's. With the example below, you can also configure another HWI beside the IPC one and use it.

      Regards,
      Bernd

      bool configureIPCInterrupt(void)
      {
          Hwi_Params         sHwiParams;
          Hwi_Handle         HwiHandle;
          Error_Block     ErrorBlock;

          Error_init(&ErrorBlock);
          Hwi_Params_init(&sHwiParams);
          sHwiParams.arg = 9;
          sHwiParams.eventId = CSL_GEM_IPC_LOCAL;
          sHwiParams.enableInt = true;
          HwiHandle = Hwi_create(4, IPCHandler, &sHwiParams, &ErrorBlock);
          if(HwiHandle == NULL)
          {
              return false;
          }
          Hwi_enable();

          return true;
      }

      void IPCHandler(UArg uarg)
      {
          DEVICE_REG32_W(IPCAR(DNUM), IPCSOURCE);
          DEVICE_REG32_W(0x80000200 + 4*DNUM, 0xBABEFACE);
          while(1) ;
      }

      Trigger IPC for core 1:

      #define IPCGR(x)                (0x02620240 + x * 4)
      #define IPCAR(x)                (0x02620280 + x * 4)
      #define IPCSOURCE         (0x10)
      DEVICE_REG32_W(IPCGR(1), IPCSOURCE | 0x1);

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use