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.

RTOS/TMS320F28379D: SYS/BIOS best way to get time in milliseconds

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: TI-RTOS

Hi,

I am trying to get system time (time since application execution started) in milliseconds. I have the next cfg settings:

- CPU clock frequency (Hz) = 2500000.

- Clock Manager Enabled

- Clock Module:

- Internally configure a Timer to periodically call Clock_tick()

- Tick period (us) = 1000

- Timer id = ANY

But then when I call Clock_getTicks() it returns incoherent values. I understand that each tick is 1 millisecond, so if this function returns for example 12345 it means that since execution started 12345 milliseconds have passed. Am I properly interpreting Clock_getTicsk() function? Any idea of what is going on?

I have also tried to accomplish it with timestamp module by calling function TimestampProvider_get64() but results have non sense.

Can anyone explain how to convert from these functions output to milliseconds?

Best regards,

Adria

  • Yes, that sounds like the appropriate interpretation of Clock_getTick(). Have you confirmed that your SYSCLK is running at the expected speed? Is BIOS.cpuFreq.lo set to that speed in your .cfg file? If SYS/BIOS doesn't understand at what frequency the device is actually running, the conversion from actual hardware timer ticks to SYS/BIOS ticks is going to be off which could explain strange results.

    Whitney

  • Hi Whitney,

    How can I check at what speed is SYSCLK running?

    Within the task I am trying to get system time, I call the next code from C2000Ware:

    Device_init();
    Device_initGPIO();
    GPIO_setMasterCore(70, GPIO_CORE_CPU1);
    GPIO_setPinConfig(GPIO_70_SCITXDB);
    GPIO_setDirectionMode(70, GPIO_DIR_MODE_IN);
    GPIO_setPadConfig(70, GPIO_PIN_TYPE_STD);
    GPIO_setQualificationMode(70, GPIO_QUAL_ASYNC);
    SCI_performSoftwareReset(SCI_BASE);
    SCI_setConfig(SCI_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |
                                                       SCI_CONFIG_STOP_ONE |
                                                       SCI_CONFIG_PAR_NONE));
    SCI_resetChannels(SCI_BASE);
    SCI_resetRxFIFO(SCI_BASE);
    SCI_resetTxFIFO(SCI_BASE);
    SCI_clearInterruptStatus(SCI_BASE, SCI_INT_TXFF | SCI_INT_RXFF);
    SCI_enableFIFO(SCI_BASE);
    SCI_enableModule(SCI_BASE);
    SCI_performSoftwareReset(SCI_BASE);

    This code has been copy-pasted from sci_echoback example. Do you think that it could be causing this weird result I am facing? In that case, what is the best solution to have SYS/BIOS with sci driver from C2000Ware and be able to properly use Task_sleep() function from a task.

    Best regards,

    Adria

  • There is an XCLKOUT pin mux option that you can use to output a divided down SYSCLK on a pin so that you can check its speed on an oscilloscope. See your technical reference manual for details.

    By default, Device_init() for the F28379D will set the SYSCLK for 200 Mhz. I believe the default value for BIOS.cpuFreq.lo is 2.5 Mhz. Have you updated your cfg to set BIOS.cpuFreq.lo to the actual speed? You may also need to go into the Boot module and make sure the "Configure PLL and CPU clock dividers" option is turned off as well.

    Whitney

  • Hi Whitney,

    I have checked that option with the oscilloscope and the SYSCLK is 25 MHz, which is the default value (in my case) with Device_init(). It is also the default value (25 MHz) with C2000Ware examples.
    Alright, then the problem is that I configure SYS/BIOS to make it believe that SYSCLK is 2.5 MHz but from code I set it to 25MHz, which then explains why Clock_getTicks() returns those incoherent values.
    When I try to set BIOS.cpuFreq.lo to 25 MHz, I get an error which says: "BIOS.cpuFreq (25000000 Hz) does not match the actual CPU frequency (2500000 Hz). Please program the Boot module's PLL settings to ensure the actual CPU frequency matches BIOS.cpuFreq.". And, as I work on Ubuntu 18.04 I am facing a problem when it comes to edit cfg file through XGCONF. I cannot edit anything related to Boot module. But, as I can edit cfg text file, could you please tell me how to configure cfg boot module by editing text, indicating how to write the lines? And, where is it exactly (document and section or page) documented?

    Best regards,

    Adria
  • Hi Whitney,

    Right after answering your last post I could edit the boot module in cfg file.

    Then, let's resume my cfg set up:

    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var Diags = xdc.useModule('xdc.runtime.Diags');
    var Error = xdc.useModule('xdc.runtime.Error');
    var Log = xdc.useModule('xdc.runtime.Log');
    var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
    var Main = xdc.useModule('xdc.runtime.Main');
    var Memory = xdc.useModule('xdc.runtime.Memory')
    var SysMin = xdc.useModule('xdc.runtime.SysMin');
    var System = xdc.useModule('xdc.runtime.System');
    var Text = xdc.useModule('xdc.runtime.Text');
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    var Clock = xdc.useModule('ti.sysbios.knl.Clock');
    var Swi = xdc.useModule('ti.sysbios.knl.Swi');
    var Task = xdc.useModule('ti.sysbios.knl.Task');
    var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
    var Hwi = xdc.useModule('ti.sysbios.family.c28.Hwi');
    var Boot = xdc.useModule('ti.catalog.c2800.initF2837x.Boot');
    System.maxAtexitHandlers = 4;
    BIOS.heapSize = 0x800;
    BIOS.libType = BIOS.LibType_Custom;
    Program.stack = 0x200;
    SysMin.bufSize = 0x100;
    var loggerBufParams = new LoggerBuf.Params();
    loggerBufParams.numEntries = 32;
    var logger0 = LoggerBuf.create(loggerBufParams);
    Defaults.common$.logger = logger0;
    Main.common$.diags_INFO = Diags.ALWAYS_ON;
    System.SupportProxy = SysMin;
    SysMin.flushAtExit = true;
    Clock.timerId = -1;
    Clock.tickSource = Clock.TickSource_TIMER;
    Clock.tickPeriod = 1000;
    BIOS.cpuFreq.lo = 25000000;
    Boot.configureClocks = false;
    Boot.configureFlashController = false;

    And I verify that I keep having a 25 MHz SYSCLK.

    Now Clock_getTicks() is returning less strange values but they are not correct yet. Seeing my configuration, shouldn't I get spent milliseconds from Clock_getTicks()? I am getting something like milliseconds multiplied by 10, and not really accurate because if I compare how time increases with a chronometer, the chronometer goes faster (of course, if I ignore the 10 factor which seems to be added).

    Best regards,

    Adria

  • Is 25 MHz what you actually measured on the pin? There is a divider in the XCLKOUT path that divides it down before putting it on the pin. By default this is divide by 8. Did you reconfigure the divider? If not, it sounds like you may be running at 200 MHz (25 * 8). That's not exactly a factor of 10 but it could explain it. If you set BIOS.cpuFreq.lo to 200000000 does it get better?

    Whitney

  • Hi Whitney,

    Sorry for the delay in my response, but I was on Christmas holidays.

    XCLKOUT divider was the problem, I cannot change its value programmatically and still don't know why. I have only been able to change it through "Registers" view in CCS thanks to this question:

    After understanding a little bit more about SYS/BIOS CPU frequency and clock and its compatibility with C2000Ware I have finally got Clock_getTicks() routine properly working. The problem was, as you mentioned before, an incompatibility between the CPU frequency configured by C2000Ware and the one specified to SYS/BIOS cfg.

    Best regards,

    Adria