FlexIO Set source clock API difference

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

FlexIO Set source clock API difference

Jump to solution
740 Views
lucasrangit
Contributor III

Setting the FlexIO source clock is required in order to support a desired SCL clock rate range (as explained in Problem with clock rate in FlexIO I2C ).

In the following SDK functions, do the source clock arguments refer to the same clock? If so, is there a way to go from the 2-bit "src" in CLOCK_SetFlexio0Clock defined in the MCU datasheet to Hz? Similar to using CLOCK_GetFreq(clock_name_t clockName).

Secondly, does a deinit and reinit of the FlexIO bus to change the SCL clock rate require a call both functions (e.g. when changing the source clock to achieve a frequency outside the current range)?

/*!
 * @brief Set FLEXIO clock source.
 *
 * @param src The value to set FLEXIO clock source.
 */
static inline void CLOCK_SetFlexio0Clock(uint32_t src)
{
 SIM->SOPT2 = ((SIM->SOPT2 & ~SIM_SOPT2_FLEXIOSRC_MASK) | SIM_SOPT2_FLEXIOSRC(src));
}‍‍‍‍‍‍‍‍‍
/*!
 * @brief Ungates the FlexIO clock, resets the FlexIO module, and configures the FlexIO I2C
 * hardware configuration.
 *
 * Example
 @code
 FLEXIO_I2C_Type base = {
 .flexioBase = FLEXIO,
 .SDAPinIndex = 0,
 .SCLPinIndex = 1,
 .shifterIndex = {0,1},
 .timerIndex = {0,1}
 };
 flexio_i2c_master_config_t config = {
 .enableInDoze = false,
 .enableInDebug = true,
 .enableFastAccess = false,
 .baudRate_Bps = 100000
 };
 FLEXIO_I2C_MasterInit(base, &config, srcClock_Hz);
 @endcode
 *
 * @param base Pointer to FLEXIO_I2C_Type structure.
 * @param masterConfig Pointer to flexio_i2c_master_config_t structure.
 * @param srcClock_Hz FlexIO source clock in Hz.
*/
void FLEXIO_I2C_MasterInit(FLEXIO_I2C_Type *base, flexio_i2c_master_config_t *masterConfig, uint32_t srcClock_Hz);
Labels (1)
Tags (3)
0 Kudos
1 Solution
562 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

The KL17 reference manual shows the FlexIO module clock source below:

pastedImage_1.png

MCGPCLK is clock output from IRC48M (48MHz);

MCGIRCLK is clock output from IRC8M (IRC8M/2M internal reference clock divided by lirc_div2);

OSCERCLK is System oscillator output sourced from OSCCLK that may clock some on-chip modules (frequence same with external crystal/oscillator)

When customer call CLOCK_SetFlexio0Clock() function, customer need to clear know the FlexIO clock source frequency.

Such as FlexIO_i2c [interrupt_i2c_transfer] demo using MCGPCLK as clock source, which is fixed to 48MHz.

So, the FLEXIO_CLOCK_FREQUENCY macro definition value is 48MHz.

#define FLEXIO_CLOCK_FREQUENCY 48000000U

If customer change to use another clock source, customer need to set the correct clock frequency at FLEXIO_CLOCK_FREQUENCY macro.

Thank you for the attention. 


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
563 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

The KL17 reference manual shows the FlexIO module clock source below:

pastedImage_1.png

MCGPCLK is clock output from IRC48M (48MHz);

MCGIRCLK is clock output from IRC8M (IRC8M/2M internal reference clock divided by lirc_div2);

OSCERCLK is System oscillator output sourced from OSCCLK that may clock some on-chip modules (frequence same with external crystal/oscillator)

When customer call CLOCK_SetFlexio0Clock() function, customer need to clear know the FlexIO clock source frequency.

Such as FlexIO_i2c [interrupt_i2c_transfer] demo using MCGPCLK as clock source, which is fixed to 48MHz.

So, the FLEXIO_CLOCK_FREQUENCY macro definition value is 48MHz.

#define FLEXIO_CLOCK_FREQUENCY 48000000U

If customer change to use another clock source, customer need to set the correct clock frequency at FLEXIO_CLOCK_FREQUENCY macro.

Thank you for the attention. 


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos