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.

AM335x DMTimer clock source in Bootloader

Other Parts Discussed in Thread: AM3352, AM3359

Hi,

In our AM3352 (SYS/BIOS) based application we want to use CLK_M_OSC accurate timing.
is there any way to change the Dmtimer clock source to CLK_M_OSC in the bootloader?

The bootloader stops working if we add the below code in order to change the
clock source to CLK_M_OSC.

 HWREG(SOC_CM_DPLL_REGS + CM_DPLL_CLKSEL_TIMER2_CLK) &=
          ~(CM_DPLL_CLKSEL_TIMER2_CLK_CLKSEL);

 while((HWREG(SOC_CM_DPLL_REGS + CM_DPLL_CLKSEL_TIMER2_CLK) &
           CM_DPLL_CLKSEL_TIMER2_CLK_CLKSEL) !=
           CM_DPLL_CLKSEL_TIMER2_CLK_CLKSEL_CLK_M_OSC);

The bootloader works properly if we remove above code but the timing accuracy is bad
which I believe 32KHz will be used instead of CLK_M_OSC.

Please let me know if there is any reference or any way to change the Dmtimer clock
source in the Bootloader.

Best Regards
Kummi

  • The RTOS team have been notified. They will respond here.
  • Hi,

    Please let me know if there is any suggestions.
    If I add the above code to the main program, the program stops
    at this code.

    Best Regards
    Kummi.
  • Sorry for the delay. I have escalated the request.
  • Kummi,

    Please look at the DMtimer2ModuleClkConfig function for reference code to set the clock source to CLK_M_OSC.

    HEre is the code that you can try :

    /* Clear CLKSEL field of CM_DPLL_CLKSEL_TIMER2_CLK register. */
        HWREG(SOC_CM_DPLL_REGS + CM_DPLL_CLKSEL_TIMER2_CLK) &=
              ~(CM_DPLL_CLKSEL_TIMER2_CLK_CLKSEL);
    
        /* Writing to the CLKSEL field of CM_DPLL_CLKSEL_TIMER2_CLK register. */
        HWREG(SOC_CM_DPLL_REGS + CM_DPLL_CLKSEL_TIMER2_CLK) |=
              CM_DPLL_CLKSEL_TIMER2_CLK_CLKSEL_CLK_M_OSC;
    
        /* Waiting for the CLKSEL field to reflect the written value. */
        while((HWREG(SOC_CM_DPLL_REGS + CM_DPLL_CLKSEL_TIMER2_CLK) &
               CM_DPLL_CLKSEL_TIMER2_CLK_CLKSEL) !=
               CM_DPLL_CLKSEL_TIMER2_CLK_CLKSEL_CLK_M_OSC);

    If this doesn`t work, please read the CLKSEL_TIMER2_CLK register value from Memory browser, and let us know. I am assuming you have unlocked KICK registers and all lock mechanisms that could prevent writes to that register.

    Regards,

    Rahul

  • Hi Rahul,

    Thank you so much for the information.
    I will come back with the CLKSEL_TIMER2_CLK register value,
    currently debugging a different application.

    Meanwhile, I couldn't find the details about unlocking the KICK registers.
    The manual says the KICK registers are for RTC.
    Please let me know if there is any reference code for unlocking the registers.

    The starterware sample code(like dmtimerCounter.c) don't have code meant for unlocking.

    int main(void)

    {
        
      DMTimer2ModuleClkConfig();
    ......

    Best Regards
    Kummi

  • Kummi,

    The KICK register are described in section 20.3.4 of the technical Reference manual for AM3359 (Rev O ) that is on the product folder here:
    www.ti.com/.../spruh73o.pdf

    Starterware code provides code to lock and unlock the KICK registers. You can find the functions RTCWriteProtectEnable and RTCWriteProtectDisable in the file rtc.c under drivers folder in Starterware. This a a very simple mechanism to lock and unlock tot write to the RTC registers on the device:

    Hope this helps. Let us know if there is anything else we can help with.

    Regards,
    Rahul
  • Hi Rahul,

    Thank you.
    One clarification.

    As you mentioned KICK registers are for RTC,
    but my question is about  DMTimer.
    Is it required to unlock KICK registers for DMTimer also?

    Best Regards
    Kummi

  • for configuring the DMtimer, here is the recommended API flow:
    processors.wiki.ti.com/.../StarterWare_DMTimer

    KICK register only impacts RTC configuration registers.

    Regards,
    Rahul
  • Hi Rahul,

    Thank you so much.

    We are still not able to solve the issue and we need your help.
    We believe the settings for DMtimer is as per the guide and sample code,
    and we can see the clock source is changed to CLK_M_OSC.

    But the problem is if we add the DMtimer2 function DMtimer2ModuleClkConfig()
    into the main() function the application stops working.
    We get WDT reset at BIOS_Start().

    Please let me know what could be the possible reason for the WDT to get reset
    at the BIOS_Start().

    Best Regards
    Kummi
  • Hi Rahul,

    Finally found the problem.

    It seems we cannot use DMtimer2ModuleClkConfig() function to set the clock source to CLK_M_OSC.
    As this DMtimer is used by SYS/BIOS, the DMTimer startup code that runs before main () validates
    the DMTimer frequency and we get the Frequency mismatch error as mentioned in the below E2E.
    e2e.ti.com/.../1075974

    The possible solution is changing the DMTimer clock source before the Main() function.

    We added this code before the main() function and it worked.

    #define PRCM_BASE_ADDR (0x44E00000)

    #define CM_PER_TIMER2_CLKCTRL = 0x2 (0x80 + PRCM_BASE_ADDR)
    #define CLKSEL_TIMER2_CLK = 0x1 (0x508 + PRCM_BASE_ADDR)

    Please let me know if the above understanding and the solution is correct.

    Best Regards
    Kummi