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.

How can I change a clock source of one of timer4 ~ 7 in C6670 ?

Currently, I'm using C6670 (with SYS/BIOS v6.33.5.46) and have 2 questions.

As you know, C6670 has eight timers.
Timer0 ~ 3 are dedicated to each of cores.
Timer4 ~ 7 are shared by cores.
All of them are clocking based on SYSCLK.

Q1. Can I change the clock source of one of Timer4 ~ Timer7 to use external clock instead of SYSCLK ?
    (The external clock will be entered in TIMI0 port in C6670.)
Q2. If Yes.. Where can I get any example codes or documents ?
    And, Which one is easier to use, SYS/BIOS APIs or CSL APIs ?

Thanks in advanced.

Kyung-Yeol

  • Yes, you can use TIMI0 or TIMI1 port as external clock source for Timers4-7 as documented in the Keystone 64 bit Timer User Guide.

    There is example code in the CSL for timers, it should be easily adapted to support external timer.

    Best Regards,
    Chad

  • Hi, Chad.

    I got the example code (timer_test.c) from "C:\ti\pdk_C6678_1_0_0_21\packages\ti\csl\example\timer" in my directory.
    There were 6 test modes about timer in the example code.
    But, I only concerned about the "General Purpose Timer" mode because Timer4 ~ Timer7 can be configured as a general-purpose timer only.
    (It was described in your TI document (SPRS689D.pdf page210 line #7)).

     ==================================================================================

    At first, I inserts the external clock having 50Hz to TIMI0 port as an external source.
    In the example code, I changed 2 things.

    1. changed the event ID from "CSL_GEM_TINTLN" to "CSL_GEM_TINT4L".
    2. inserted 2 lines as below :


        /* Set the timer mode to 64bit GP Timer Mode and set the PRD registers */
        hwSetup.tmrTimerMode     = CSL_TMR_TIMMODE_GPT;
        hwSetup.tmrTimerPeriodLo = 0x0f;
        hwSetup.tmrTimerPeriodHi = 0x00;
        hwSetup.tmrClksrcLo = CSL_TMR_CLKSRC_TMRINP; <-- inserted line
        hwSetup.tmrInvInpLo = CSL_TMR_INVINP_INVERTED; <-- inserted line
        CSL_tmrHwSetup(hTmr, &hwSetup);

    And I just waited the interrrupt service routine. But nothing happened !!!

    What was wrong? What do I have to do more ?

    Thanks.

    Kyung-Yeol Sohn

  • Please check the following items in your setup:

    1. If TINPLSEL4 bit in TINPSEL register (section 3.3.16 in C6670 data manual) is 0, which selects TIMI0 as input.

    2. If CLKSRC_LO bit in TCR register of Timer module (section 5.5 in Timer user guide) is indeed set to 1 (after your CSL update).

    3. In your timer test code, if you changed "test_gp_timer(CSL_TMR_0)" to "test_gp_timer(CSL_TMR_4)" for your Timer4 testing.

    4. If your are using the correct CSL library for C6670 testing (not C6678 library).

    5. If the above are not working, could you please use the original Timer test case and only change the CSL_TMR_0 to CSL_TMR_4 and CSL_GEM_TINTLN to CSL_GEM_TINT4L and see if the internal clock source could trigger the Timer 4 interrupt in your setup please?

  • I am attempting to do something similar with a C6678 and with sys/bios.

    Is there any example of how to set a timer's external clock to the TIMI1 pin using sys/bios?

    -Dan