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 1ms clock at 19.2MHz

Other Parts Discussed in Thread: SYSBIOS

The Am335x on our custom board runs at 19.2MHz instead of 24MHz.  What do we need to add to the .cfg file to inform SysBios to use 19.2MHz when configuring the 1ms system clock?

  • Hi Henlee,

    To change the timer frequency in SYS/BIOS you need to add the following to your config file:

    var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
    Timer.intFreqs[index] = {hi: 0, lo: 19200000};

    Where index is the SYS/BIOS timer ID.  Please remember that timer IDs do not necessarily match the number in the peripheral name.  For example on AM335x SYS/BIOS Timer 0 actually corresponds to DMTimer2 on the device.  Use the Timer Mapping Table to determine which timer corresponds to each Timer ID.

    Regards,

    -- Emmanuel

  • This line is already in the config file:

    var Timer = xdc.useModule('ti.sysbios.hal.Timer');

    Do the two lines you suggested replace this one?

    I verified that DMTimer2 (index 0) is the only timer displayed in the ROV. 

    Does SysBios always use DMTimer2 for the the 1ms system clock on Am335x if no other timer is configured?

  • Replacing the two lines gives this exception:
    [CortxA8] ti.sysbios.timers.dmtimer.Timer: line 1132: E_freqMismatch: Frequency mismatch: Expected 19200000 Hz, actual: 32770 Hz. You need to modify Timer.intFreq.lo to match the actual frequency.
    xdc.runtime.Error.raise: terminating execution
  • Here is the actual code from the config file (note index 0):

    var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
    Timer.intFreqs[0] = {hi: 0, lo: 19200000}; // 19.2MHz clock source for 1ms tick
  • Hi Henlee,

    My mistake, I thought you had already configured the HW and only needed to inform BIOS of the change.  

    The error above is raised when there is a discrepancy between the BIOS CPU frequency and the Timer frequency.  Firstly,  have you already configured your PLL to generate the MPU clock you desire?  If not, please see section 8.1.6.9.1 of the AM335x TRM for the steps.  After configuring the PLL, you should know the actual system frequency will be (for example: 720 MHz).

    Now you need to tell BIOS what the actual CPU frequency is; this can be done by adding the following to your *.cfg file:

    BIOS.cpuFreq.lo = 720000000;

    Assuming you did not change the CLKSEL_TIMER2_CLK register mux value (defaul 0x01 which uses CLK_M_OSC), you need to add the Timer configuration I had mentioned above.  

    henlee said:

    var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
    Timer.intFreqs[0] = {hi: 0, lo: 19200000}; // 19.2MHz clock source for 1ms tick

    henlee said:

    Does SysBios always use DMTimer2 for the the 1ms system clock on Am335x if no other timer is configured?

    If no timer has been explicitly specified BIOS will use the first time available (DMTimer2).  However, you can explicitly tell the Clock to use a particular timer by adding the following to your .cfg file:

    Clock.timerId = 0;

    Hope this helps,

    -- Emmanuel

  • I finally got back on this.

    The problem is CLKSEL_TIMER2_CLK = 0x02 (CLK_32KHZ) when SysBios starts. The .gel file does not contain any reference to this register, or at least I can't find any reference to that constant or address. TRM spruh73L Sec. 8.1.12.3.2 says CLKSEL is 0x01 (CLK_M_OSC) after reset. Assuming this is correct, something is changing the register value before SysBios starts. Does any SysBios startup code run before BIOS_start() is called?

    The 1ms clock works correctly when CLKSEL_TIMER2_CLK is written explicitly as shown below.

    1. app.cfg
    var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
    BIOS.cpuFreq.hi = 0;
    BIOS.cpuFreq.lo = 600000000;
    Timer.intFreqs[0].hi = 0;
    Timer.intFreqs[0].lo = 19200000;
    Clock.timerId = 0; // DMTimer2 (bios_6_40_01_15/docs/cdoc/ti/sysbios/timers/dmtimer/doc-files/TimerTables.html)

    2. main.cpp
    HWREG(SOC_CM_DPLL_REGS + CM_DPLL_CLKSEL_TIMER2_CLK) =
    CM_DPLL_CLKSEL_TIMER2_CLK_CLKSEL_CLK_M_OSC; //
    ...
    BIOS_start();