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.

TM4C1294NCPDT: SysCtlClockGet() is giving me 1017.xx M value

Part Number: TM4C1294NCPDT

I m configuring my clock using 

g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

here  g_ui32SysClock gives the right value that is 12 Mega

but i want to confirm either the clock is accurate or not 

is there a method to calculate the clock 

if so please help

Thanks in advance 

  • Hi Tayyab,

     For TM4C129 device please use the returned value from SysctlClockFreqSet() to obtain the processor clock rate instead of calling SysCtlClockGet(). The SysCtlClockGet() can only be called on TM4C123 devices. This is mentioned in the TivaWare library.

    26.2.2.3 SysCtlClockGet
    Gets the processor clock rate.
    Prototype:
    uint32_t
    SysCtlClockGet(void)
    Description:
    This function determines the clock rate of the processor clock, which is also the clock rate
    of the peripheral modules (with the exception of PWM, which has its own clock divider; other
    peripherals may have different clocking, see the device data sheet for details).

    Note:
    This cannot return accurate results if SysCtlClockSet() has not been called to configure the
    clocking of the device, or if the device is directly clocked from a crystal (or a clock source)
    that is not one of the supported crystal frequencies. In the latter case, this function should be
    modified to directly return the correct system clock rate.
    This function can only be called on TM4C123 devices. For TM4C129 devices, the return value
    from SysCtlClockFreqSet() indicates the system clock frequency.

  • Thanks
    Charles Tsai


    like i already mentioned g_ui32SysClock is given the exact value that i request

    But i want to confirm either my clock is accurate or not using any other method

    please suggest me a solution to the problem i am referring.

    Thanks
  • Hi,
    You can observe the clock on the scope using the DIVSCLK pin.
  • I HAVE TRIED THIS BUT IT DIDNT SHOWED ANYTHING
    GLAD IF U CAN HELP

    code is attached

    uint32_t g_ui32SysClock= MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 30000000);


    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);

    //
    // Check if the peripheral access is enabled.
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOQ))
    {
    }

    GPIOPinTypeDIVSCLK(GPIO_PORTQ_BASE,0X10);
    SysCtlClockOutConfig(SYSCTL_CLKOUT_EN | SYSCTL_CLKOUT_SYSCLK ,1000);
  • Tayyab Tahir said:

    here  g_ui32SysClock gives the right value that is 12 Mega

    but i want to confirm either the clock is accurate or not.

    Based upon your (earlier) code entry: "...| SYSCTL_CFG_VCO_480), 120000000);"  should not that SysClock be 120MHz - NOT 12MHz?

    You also seek to confirm the accuracy of the System Clock.    Yet - you do not specify, "How that accuracy is to be measured & determined?"  That's of (some) importance - is it not?

    Consider the following:

    • you seek to "confirm SysClock accuracy" using (only) your MCU.      If that (MCU alone) is your "only means of measurement" - how then do you propose to achieve measurement accuracy?
    • to overcome that shortfall - you must provide a, "sufficiently accurate" external frequency source;" or you may output a replica of SysClock - and using external equipment - measure that.    (i.e. that was friend/vendor David's suggestion)

    While your post is "unclear" as to which of those 2 methods you seek - my sense was you "expected" the MCU (alone) "to confirm SysClock's accuracy" - which of course - minus any "on-chip" frequency standard - it cannot achieve!

    Should you seek to design a product which enables such, "Reasonably Accurate Measure of SysClock" - your provision of an adequately accurate, external, stable (voltage, age, temperature)  frequency source must be deployed (properly) upon your MCU's pcb.

    Note too that "everyone's" understanding & acceptance of  "accurate" - may NOT fully overlap your own.      Thus (some) specification IS required - is that not so?

  • thanks for your response 

    I am sorry its 120 M not 12 M.

    Also let me put it in that way 

    i want to sample the system clock on a scope or logic analyzer to check whether it is the requested clock that i mentioned in SysClockFreqSet(.......,120000000).

    if the clock could be sample on a GPIO it would be best (if possible)

    A friend of mine said that may be a PWM may help i have gone through TIVA ware documentation on search of anything related 

    could you please sample a code to do so 

    or else point me in the direction so that i can do so 

    Thanks 

  • Vendor's Charles provided the "normal/customary" means of outputting a proper "replica" of SysClock. It is suspected that your code did not properly implement his suggestion. Might your read of the MCU manual - "searching under SysClock (or similar) guide you to such detail. (sorry - firm/I do not use 4C129.)

    Should that fail - it proves reasonably simple to "Force an MCU Timer into "PWM Mode" and that outputs an integral division of the SysClock. By following the Timer code examples AND by reviewing the "Timer Section" of the Peripheral Driver User Guide - you should be able to set the Timer to 2-4 counts - thus providing an integrally scaled version of SysClock.

    Your use of a "proper Crystal and Crystal bypass caps" most always enables high confidence in frequency accuracy.
  • Hi,
    I'm able to see a 12MHz DIVSCLK using the below code sequence. Please give a try. As noted by cb1 you can also use PWM or TMR to output a periodic PWM as a means to verify the clock frequency since the PWM period is derived from the SYSCLK.

    MAP_GPIOPinConfigure(GPIO_PQ4_DIVSCLK);
    GPIODirModeSet(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_DIR_MODE_HW);
    GPIOPadConfigSet(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
    SysCtlClockOutConfig(SYSCTL_CLKOUT_EN | SYSCTL_CLKOUT_SYSCLK, 10);
  • Hi Charles,

    Most excellent - poster should (now) succeed.

    May I ask - does a similar function exist w/in "4C123 series?" (I'll search if you would be kind enough to indicate such function IS present.)

    Thanks & best regards...
  • Hi cb1,
    TM4C123 does not have DIVSCLK pin. You will need to measure PWM/TMR periods on the scope to indirectly verify if SYSCLK is correct.
  • Thank you, Charles - I did not recall seeing "DIVSCLK" w/in "4C123" manual - and (thanks to your kindness) my "visual acuity" is no longer suspect...
  • Hi cb1, You are welcome!