FlexIO Set source clock API difference

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

FlexIO Set source clock API difference

跳至解决方案
1,054 次查看
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);
标签 (1)
标记 (3)
0 项奖励
回复
1 解答
876 次查看
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 项奖励
回复
1 回复
877 次查看
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 项奖励
回复