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.

WARNING: If your input frequency isn't 24MHz, then default SYSBIOS clock is probably wrong.

Other Parts Discussed in Thread: SYSBIOS

SYSBIOS:  6.35.0.20

XDCTool:  3.24.6.63

Code Gen tools:  7.3.11

DSP:  C6748

I have discovered that our SYSBIOS clock is running at 1.25mS instead of 1mS.  After digging around the .cfg file, I can't see what I'm missing.

From the SYSBIOS -> Runtime tab, the CPU clock frequency is correctly set to 364.8MHz (this is getting pulled from the platform file).  Also on this tab I have the check next to "Enable Clock Manager".  Everything looks good here.

From the CLOCK module under Time Base I have "Internally configure a hal Timer to periodically call Clock_tick()".  Under Timer Control I have the Tick period set to 1000 and the Timer ID set to 1.  Everything looks good here.

Since we are using Timer1, its clock source is AUXCLK.  AUXCLK is the input clock frequency (we are using a crystal).  I can't find anywhere in the .cfg file where I set the input clock frequency, just the CPU clock frequency.  BIOS could figure out the input clock frequency by looking at all the PLL0 registers (PREDIV, PLLM, POSTDIV) and working things backwards.  However I remember from the BIOS5 days, that the .cfg file required you to enter the input frequency AND the final CPU frequency.

The crystal on our board is 19.2MHz.  Therefore the Timer1 PRD12 register should be loaded with 19200 for a 1mS interrupt rate.  However BIOS is loading Timer1 PRD12 with 24000, which results in 1.25mS.  BIOS is acting like there is another field somewhere in the .cfg file that sets the input frequency, and it defaults to 24MHz.

How does BIOS figure out value to load into PRD12, and am I missing a setting somewhere?

Thanks, Dean

  • Hi Dean,

    In the Timer64 module, the default frequency for C6748 Timers is 24MHz. You can change this to 19.2MHz by setting the External Input Clock Frequency in XGCONF as shown below:

    Alternatively, if you are creating the timer instance dynamically, you can set the "extFreq.lo" and "extFreq.hi" field in the Timer params to the desired frequency.

    Best,

    Ashish

  • I was told in this post, http://e2e.ti.com/support/embedded/bios/f/355/t/238055.aspx that if I'm using the "Internally configured hal Timer to periodically call Clock_tick()" that I should not include the TIMER module.  All the TIMER configuration for the automatically generated hal TIMER is done via SYSBIOS, XGCONF, XDCTOOL, whatever you want to call it (basically the GUI way to config SYSBIOS, not dynamic).

    Your suggestion seem wrong, as you leave the TIMER ISR function as null, the period to 0, etc.  Would someone else care to weigh in on this issue?

     

    - Dean

     

  • Hi Dean,

    My bad, I misread your post. You are right, the Clock() module uses an internally configured timer by default. This internally configured timer runs at the default timer frequency of 24 MHz like I mentioned before. In order to change this frequency you would need to create your own timer that runs at the right frequency and then call Clock_tick() from your timer handler.

    The first step is to configure the clock module to stop creating an internally configured timer. Here's how it can be done:

    Next, you would create your own Timer with 19.2 MHz External Frequency, set the period (1000 if you want a period of 1ms), and provide your own Timer Handler function. Within the Timer Handler function you need to add a call to Clock_tick(). Make sure to create a periodic and continuous timer.

    With he above changes, you would now be providing the tick source for the Clock module and since you create the Timer, you can control its external input frequency.

    You can find this info in the Clock module's cdoc too:

    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/bios/sysbios/6_35_00_20/exports/bios_6_35_00_20/docs/cdoc/index.html#ti/sysbios/knl/Clock.html

    Best,

    Ashish

  • We are shocked.  I don't even want to know how many embedded systems are running SYSBIOS that have the wrong clock rate.  No where in the CLOCK cdoc page does it mention 24MHz is the assumed input clock frequency, and that it can't be changed.  No where in the SYSBIOS users guide is this mentioned.  No where in the SYSBIOS online videos is this mentioned.  No where is this mentioned!!!!!

    In DSPBIOS you could setup a TIMER to drive the CLOCK module.  You could define, which timer was used, which HWI vectors was used, load the TIMER values up yourself or have DSPBIOS do it for you based on the information provided in the .cfg file.  In SYSBIOS, you can choose which TIMER to use, but you can't choose which HWI vector gets plugged.  That is some random thing SYSBIOS chooses based on what TIMER was selected.  You can't change the HWI bitmask like you could in DSPBIOS, and now we find out if your board isn't running at 24MHz, you can't use "Use Timer to automatically call Clock_tick()".  Don't you think that would have been helpful information to provide.  I don't know, maybe in the users guide, or how about a warning next to the selection?

    For anyone reading this thread, WARNING WARNING WARNING.  If you use CLOCK functions, and you have SYSBIOS automatically configure the timer for you (which is the default), and you aren't running at 24MHz, all of your timer based things will be wrong.  Clock_getTicks(), wrong.  Semaphore_pend with a timeout, wrong.  Basically anything time based that SYSBIOS needs will be wrong.

    The frustrating thing is SYSBIOS could figure out the input clock frequency given the CPU frequency.  Using the registers in PLL0 you can work backwards to figure out the input clock.  Since we no longer saw the input clock setting when moving from DSPBIOS to SYSBIOS, I assumed that is what you were doing.

    - Dean

  • Hi Dean,

    I found another simpler way to change the Clock frequency without having to change the Clock tick source.You can use the intFreqs global configuration parameter to do so. Here's some example code that you would need to add to your *.cfg file:

    var Timer = xdc.useModule('ti.sysbios.timers.timer64.Timer');
    Timer.intFreqs[Timer_Id].lo = 1920000;     
    Timer.intFreqs[Timer_Id].hi = 0;

    // Timer_Id in your case would depend on the Timer Id used by the Clock Module. You can look at Clock Module's ROV view to determine the Timer Id used by it. Or, if you are specifying the Timer Id the Clock Module should use in XGCONF then you already know what Id to use.

    Please note that if you use intFreqs[] to change the default Timer frequency, you can let the clock module internally configure the timer.

    I have filed a bug to add a Timer Frequency table to the cdoc that shows the default timer frequencies used by SYS/BIOS:

    https://cqweb.ext.ti.com/cqweb/main?command=GenerateMainFrame&service=CQ&schema=SDO-Web&contextid=SDOWP&entityID=SDOCM00100884&entityDefName=IncidentReport&username=readonly&password=readonly

    I would also like to point out that it is possible to view the timer frequency used by a particular timer if you look at the Timer module's ROV view:

    I also filed a bug to update the timer64 cdoc with an example showing how the default Timer Frequency can be modified using the intFreqs global config param:

    https://cqweb.ext.ti.com/cqweb/main?command=GenerateMainFrame&service=CQ&schema=SDO-Web&contextid=SDOWP&entityID=SDOCM00100886&entityDefName=IncidentReport&username=readonly&password=readonly

    Hope this helps!

    Best,

    Ashish

  • Ashish, thanks for providing a quick solution.  Your suggestion of modifying the .cfg file worked.  Now when I open our .cfg file using XGCONF, I see it added a new Timer module.  It has added:  SYSBIOS -> Target Specific Support -> C64P -> Timers -> Timer64 Timer.  Our DSP is the C6748.  Should we be using the C674 Target specific timer instead?  If so, how do you modify your first line to select the C674 Timer?

    For all SYSBIOS developers, this was a major oversight.  The default SYSBIOS configuration configures TIMER0 to provide the system clock ticks.  Not only have you removed the ability to change which HWI ISR vector TIMER0 uses, and what bitmask it can use, you have assumed that EVERYONE is running their project with a  24MHz input frequency.  No warnings, no mention of the 24MHz restriction, no work around (well not until one was provided by Ashish), etc.

    I strongly suggest XGCONF gets modified so EVERYTHING related to this TIMER can be accessed (HWI vector, HWI bitmask, making sure the PRD is configured correctly based on the input frequency, etc).  Leaving things hard coded and un-documented is a huge no-no.

    - Dean

  • Hi Dean,

    Dean Hofstetter said:

    Ashish, thanks for providing a quick solution.  Your suggestion of modifying the .cfg file worked.  Now when I open our .cfg file using XGCONF, I see it added a new Timer module.  It has added:  SYSBIOS -> Target Specific Support -> C64P -> Timers -> Timer64 Timer.  Our DSP is the C6748.  Should we be using the C674 Target specific timer instead?  If so, how do you modify your first line to select the C674 Timer?

    The Timer64 module also supports the C6748 device.

    You can look at the Timer Mapping Table for a list of devices supported by Timer64: http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/bios/sysbios/6_35_01_29/exports/bios_6_35_01_29/docs/cdoc/ti/sysbios/timers/timer64/doc-files/TimerTables.html

    Best,

    Ashish

  • The confusing thing is SYSBIOS presents two different Timer modules to use.

    1.  SYSBIOS -> Scheduling -> Timer.  This is the one that got added to our project with your code you suggested.

    2.  SYSBIOS -> Target Specific Support -> C674 -> Timers -> Timer.  This is the one I have the question about.  Because we are using the C6748, should we use the Target Specific Timer, or just stay with the general Timer from SYSBIOS?  If the answer is stay with the general SYSBIOS Timer, then why is even the Target Specific stuff in there?

    Thanks, Dean

  • Ashish or any other TI SYSBIOS expert, can you please answer my question about which Timer modules we should be using for the C6748?

    Thanks, Dean

  • This question comes up a lot.

    The 'portable' Timer module in 'ti.sysbios.hal.Timer' actually forwards all of its APIs and functionality to the device-specific Timer module.

    The motivation for providing the portable Timer module is that applications or drivers that needs to run on various devices will not have to conditionally #include different Timer.h files or have conditional "xdc.useModule()" entries in their config files based on the target/device.

    Alan

  • Did this ever get resolved? I just recently created a new project in CCSv5.5, and it appears the same problem still exists. SYSBIOS still assumes my board is using a 24MHz crystal (which it is not).

    Thanks, Dean
  • Hi Dean,

    I see the following status for the bugs in this thread:

    • SDOCM00100884 Add Timer Frequency Table to the cdoc (showing default frequency) for dmtimer, gptimer and Timer64 modules
      • still open
    • SDOCM00100886 Update cdoc for intFreqs config parameter in timer64 module
      • resolved in SYS/BIOS 6.40.01.15

    So, looks like the doc now shows you how to change it, but the default is still 24MHz.

    Steve

  • Hi Dean,

    Adding to Steve's post. I am not sure why the below bug is still open, but it has been fixed in SYS/BIOS 6.37+.

    • SDOCM00100884 Add Timer Frequency Table to the cdoc (showing default frequency) for dmtimer, gptimer and Timer64 module

    Also, I believe the intFreqs[] feature for changing each individual timer64 timer's frequency has been implemented in SYS/BIOS 6.37+.

    Best,

    Ashish

  • Steve / Ashish,

    I still think you have a problem. Using CCSv5.5, SYSBIOS 6.37.5.35, and XDCTools 3.25.6.96. I created a new SYSBIOS typical project. The Clock module is added automatically, and it is set to "Internally configure a hal Timer to periodically call Clock_tick()". Tick period is set to 1000uS, and Timer ID is set to ANY. The Timer module is not automatically added, and it not visible in the Outline. Furthermore, the Timer box is not checked in the SYSBIOS -> System Overview tab. Even thought the clock module claims it is using a Timer (and I believe it), nothing in XGCONF shows the Timer module is being used. There are no Instances listed in the Hwi module. Looking at the system overview from XGCONF, I can't tell what Timer is being used, what frequency that timer is using to determine the 1000uS rate, nor what HW interrupt vector is getting plugged.

    When I compile and run this project on my custom HW, and look and the ROV, I see that HW interrupt vector 14 is plugged with "ti_sysbios_knl_Clock_doTick_I" and the Event ID it is triggered from is 4. Looking in the C6748 datasheet I see that Event ID 4 is tied to Timer0. Looking at Timer from the ROV shows the period is 24000. So again, SYSBIOS is assuming the input frequency is 24MHz. My custom HW uses 19.2MHz as the input frequency.

    Is there a way I can create a poll on this forum to ask users how many use SYSBIOS with custom HW not running at 24MHz? Out of those people, I bet there are a large number not aware of this problem and their system "tick" isn't running at exactly 1mS. God only knows what that is doing to their system.

    - Dean
  • Hi Dean,

    I'll bring this up with the BIOS team and get back to you on this.

    Steve
  • Hi Dean,

    What you are seeing is expected, as the default value for the timer frequency wasn't changed.  Rather, the option to change the frequency (via the intFreqs[] array) was exposed.  So, you need to change it using the intFreqs[] array if your timer runs at a frequency other than the default.

    Steve

  • Steve, thanks for looking into it. If that is TI's final answer (using the intFreqs[] array), then that has to be one of the top ten worst decisions. Passing on 2nd down from the 1 yard line might rank higher, but not by much.

    I scanned through the SYSBIOS users guide. It has no mention of the default 24MHz, nor any instructions how to change it. If I'm a new SYSBIOS user, there is probably a 99% chance that I'll miss this important fact. The only place to find this nugget of information is on the E2E site (as far as I know). We've know about this "bug" for years, yet just recently released a product into the field running at the wrong rate because we forgot. Our fault for sure, but I'm 100% convinced it would have been caught if it was part of the SYSBIOS setup or the platform package.

    DSPBIOS had you fill in the input frequency so it can correctly figure out the timer values, but SYSBIOS always assumes 24MHz, because who would use anything else??? TI has a bad habit of assuming everyone uses their EVM boards, and/or has copied such and such schematic. I strongly urge TI to change their mind an implement something in the project setup (platform file, SYSBIOS Runtime tab, etc) that allows you to set the input frequency. Furthermore, when the Clock module is setup to internally configure a HAL timer, the clock module should tell you which Timer it is using, what HWI interrupt vector it plugged, and allow you to configure the interrupt mask.

    - Dean
  • Bump.  This needs to be fixed.