K40 BSP API function to obtain system clock setting

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K40 BSP API function to obtain system clock setting

Jump to solution
964 Views
sriramchadalava
Contributor III

Dear community,

    What is the API function in K series(For example, K40) BSP to obtain current system clock value?

    In some of the low level DSPI driver code provided by Freescale, this function has been used:

  clock_speed = _bsp_get_clock(_bsp_get_clock_configuration(), dspi_info_ptr->CLOCK_SOURCE);

    However, unless I'm missing something, the second parameter cannot be accessed by a higher level driver.

    My question is whether there is any other function to obtain the system clock or some way the second parameter in the above function is accessible from higher level driver code.

Thanks.

1 Solution
716 Views
Martin_
NXP Employee
NXP Employee

Hi Sriram,

check this

_mqx_uint fsys;

fsys = _time_get_ticks_per_sec() * _time_get_hwticks_per_tick();

printf("fsys= %i\n", fsys);

View solution in original post

5 Replies
716 Views
c0170
Senior Contributor III

Hello Sriram Chadalavada,

take a look into freq_change example, it uses _cm_get_clock(void). This function is part of cm driver located in io/cm, where are other function which you might find useful. This particular:

BSP_CLOCK_CONFIGURATION _cm_get_clock_configuration

(

    void

)

{

    return _bsp_get_clock_configuration();

}

Regards,

MartinK

0 Kudos
716 Views
sriramchadalava
Contributor III

Hi Kojto,

Thanks for the response. I'll take a look at the code in freq_change example.

But the code you've posted also returns a BSP_CLOCK_CONFIGURATION type. One still needs to extract the clock speed from this, for example, by using the function call I cited in my initial post. My question was if there is a way to avoid that?

0 Kudos
717 Views
Martin_
NXP Employee
NXP Employee

Hi Sriram,

check this

_mqx_uint fsys;

fsys = _time_get_ticks_per_sec() * _time_get_hwticks_per_tick();

printf("fsys= %i\n", fsys);

716 Views
sriramchadalava
Contributor III

Thanks Martin :smileyhappy:.

One question though. What is the upper bound of _mqx_int data type?

0 Kudos
716 Views
c0170
Senior Contributor III

check core psp,  mqx/source/psp/cortex_m , there's psptypes header file where are typedef's .

#ifndef USE_32BIT_TYPES

/* Type for the CPU's natural size */

typedef uint_32  _mqx_uint, _PTR_ _mqx_uint_ptr;

typedef int_32   _mqx_int,  _PTR_ _mqx_int_ptr;

/* How big a data pointer is on this processor */

typedef uint_32  _psp_data_addr, _PTR_ _psp_data_addr_ptr;

/* How big a code pointer is on this processor */

typedef uint_32  _psp_code_addr, _PTR_ _psp_code_addr_ptr;

/* Maximum type */

typedef uint_32  _mqx_max_type, _PTR_ _mqx_max_type_ptr;

/* _mem_size is equated to the a type that can hold the maximum data address */

typedef uint_32 _mem_size, _PTR_ _mem_size_ptr;

/* Used for file sizes. */

typedef uint_32       _file_size;

typedef int_32        _file_offset;

#else

#define _mqx_uint      uint_32

#define _mqx_uint_ptr  uint_32_ptr

#define _mqx_int       int_32

#define _mqx_int_ptr   int_32_ptr

#define _psp_data_addr uint_32

#define _psp_code_addr uint_32

#define _mqx_max_type  uint_32

#define _mem_size      uint_32

#endif