I2c clock frequency issue

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

I2c clock frequency issue

3,239 次查看
divyanshu_kumar
Contributor I

Hi,

I am using I2c0 of LPC824 max board in that I configure i2c speed as 400kHz but got  330 kHz only. For 100khz it is coming correct approximately 99khz. can anybody suggest what need to do.

 
0 项奖励
回复
7 回复数

3,232 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Your  colleague said that you use the internal clock source, can you tell us the value of MAINCLKSEL reg? it determines the clock source of the system clock and IIC.

BR

XiangJun Rong

 

xiangjun_rong_0-1604310706727.png

 

0 项奖励
回复

3,225 次查看
divyanshu_kumar
Contributor I

Hi Rong,

I used Internal IRC oscillator.

Please find the below code of initialization of clock.

when we increased the frequency to 440khz than we are getting  400khz. 

 

void BOARD_BootClockIRC12M(void)
{
/*!< Set up the clock sources */
/*!< Set up IRC */
POWER_DisablePD(kPDRUNCFG_PD_IRC_OUT); /*!< Ensure IRC OUT is on */
POWER_DisablePD(kPDRUNCFG_PD_IRC); /*!< Ensure IRC is on */
CLOCK_Select(kSYSPLL_From_Irc); /*!< set IRC to pll select */
clock_sys_pll_t config;
config.src=kCLOCK_SysPllSrcIrc; /*!< set pll src */
config.targetFreq = 12000000U; /*!< set pll target freq */
CLOCK_InitSystemPll(&config); /*!< set parameters */
CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcIrc); /*!< select irc for main clock */
CLOCK_Select(kCLKOUT_From_Irc); /*!< select IRC for CLKOUT */
CLOCK_SetCoreSysClkDiv(1U);
/*!< Set SystemCoreClock variable. */
SystemCoreClock = BOARD_BOOTCLOCKIRC12M_CORE_CLOCK;

0 项奖励
回复

3,214 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

From your code, you output the 12MHz IRC clock to the CLKO pin, it is okay, with the scope, you can test the IRC clock frequency. BTW, you can output the main clock to the CLKO pin and test it's frequency. The I2C clock frequency is main_clock/[SYSAHBCLKDIV*I2C_CLKDIV*(MSTSCLLOW+MSTSCLHIGH in MSTTIME reg)].

Hope it can help you

BR

XiangJun Rong

 

xiangjun_rong_0-1604370953429.png

 

 

0 项奖励
回复

3,190 次查看
divyanshu_kumar
Contributor I

Hi,

Please share the sample code to get internal frequency on clkout pin. I configured po24 pin in swm setting but didn't get any output.

please provide the solution as soon as possible consider it as urgent.  

0 项奖励
回复

3,204 次查看
divyanshu_kumar
Contributor I

Hi Rong,

I used pio24 pin for clkout pin, i am not getting any output. Do you have any example code. 

0 项奖励
回复

3,183 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Kumar,

This code route the CLKOUT_0 signal to PIO0_19, but I do not test it, pls have a try.

BR

XiangJun Rong

 


#include "fsl_SWM_connections.h"

#include "fsl_swm.h"

void ClkoutPinAssignment(void);

 

void ClkoutPinAssignment(void)
{
//enable SWM clock
CLOCK_EnableClock(kCLOCK_Swm);
//output CLKOUT signal to PIO19
SWM_SetMovablePinSelect(SWM0,kSWM_CLKOUT,kSWM_PortPin_P0_19);

}

0 项奖励
回复

3,166 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I have tested the code on my LPC824 board, with which the CLKOUT outputs to PIO0_19 with main clock source. It works fine.

BR

XiangJun Rong

void ClkoutPinAssignment(void)
{
//enable SWM clock
CLOCK_EnableClock(kCLOCK_Swm);
//output CLKOUT signal to PIO19
SWM_SetMovablePinSelect(SWM0,kSWM_CLKOUT,kSWM_PortPin_P0_19);
SYSCON->CLKOUTUEN&=~(0x01);
SYSCON->CLKOUTSEL=0x03;
SYSCON->CLKOUTDIV=0xFF;
SYSCON->CLKOUTUEN|=0x01;


}

0 项奖励
回复