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.
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
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;
}
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
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.
Hi Rong,
I used pio24 pin for clkout pin, i am not getting any output. Do you have any example code.
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);
}
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;
}