在线时间9 小时
UID155127
注册时间2009-10-19
NXP金币0
该用户从未签到
注册会员

- 积分
- 110
- 最后登录
- 1970-1-1
|
本帖最后由 FSL_TICS_ZJJ 于 2015-12-28 16:35 编辑
您好!
问题:1) KL03外接32.768K晶振时,是否需要负载电容Cx,Cy和Rf反馈电阻?如果需要,参数一般是多少?
我在KL03的使用手册上看到如下:
25.6 External Crystal / Resonator Connections
The connections for a crystal/resonator frequency reference are shown in the figures
found here.
When using low-frequency, low-power mode, the only external component is the crystal
or ceramic resonator itself. In the other oscillator modes, load capacitors (Cx, Cy) and
feedback resistor (RF) are required. The following table shows all possible connections.
[size=18.6667px] 这里的意思是否说:如果连接32.768K低频晶振,就不需要负载电容和反馈电阻??
问题: 2) 我的项目对时钟的分配如下:
运行使用内部48MHz来运行,睡眠时使用32.768K作为TPM0时钟源定时唤醒。
我现在的初始化代码如下,但是发现没有等待32.768K启振稳定的过程,就直接运行代码后续代码了。
请问如何配置才是正确的??
- //------------------------------------------------------------------------------
- void BOARD_ClockInit(void)
- {
- /* Set allowed power mode, allow all. */
- SMC_HAL_SetProtection(SMC, kAllowPowerModeAll);
-
- DbgPinCpl();
- DbgPinCpl();
-
- /* Setup board clock source. */
- // Setup OSC0 if used.
- // Configure OSC0 pin mux.
- PORT_HAL_SetMuxMode(EXTAL0_PORT, EXTAL0_PIN, EXTAL0_PINMUX);
- PORT_HAL_SetMuxMode(XTAL0_PORT, XTAL0_PIN, XTAL0_PINMUX);
- BOARD_InitOsc0();
- DbgPinCpl();
- DbgPinCpl();
- // Setup RTC external clock if used.
- BOARD_InitRtcOsc();
- DbgPinCpl();
- DbgPinCpl();
- /* Set system clock configuration. */
- CLOCK_SYS_SetConfiguration(&g_defaultClockConfigRun);
- }
- //------------------------------------------------------------------------------
- /* OSC0 configuration. */
- #define OSC0_XTAL_FREQ 32768U
- #define OSC0_SC2P_ENABLE_CONFIG false
- #define OSC0_SC4P_ENABLE_CONFIG false
- #define OSC0_SC8P_ENABLE_CONFIG false
- #define OSC0_SC16P_ENABLE_CONFIG false
- #define MCG_EREFS0 kOscSrcOsc
- void BOARD_InitOsc0(void)
- {
- // OSC0 configuration.
- osc_user_config_t osc0Config =
- {
- .freq = OSC0_XTAL_FREQ,
- .erefs = MCG_EREFS0,
- .enableCapacitor2p = OSC0_SC2P_ENABLE_CONFIG,
- .enableCapacitor4p = OSC0_SC4P_ENABLE_CONFIG,
- .enableCapacitor8p = OSC0_SC8P_ENABLE_CONFIG,
- .enableCapacitor16p = OSC0_SC16P_ENABLE_CONFIG,
- };
- CLOCK_SYS_OscInit(0U, &osc0Config);
- }
- //------------------------------------------------------------------------------
- /* RTC external clock configuration. */
- #define RTC_XTAL_FREQ 0U
- #define RTC_SC2P_ENABLE_CONFIG false
- #define RTC_SC4P_ENABLE_CONFIG false
- #define RTC_SC8P_ENABLE_CONFIG false
- #define RTC_SC16P_ENABLE_CONFIG false
- #define RTC_OSC_ENABLE_CONFIG false
- #define RTC_CLK_OUTPUT_ENABLE_CONFIG false
- /* Function to initialize RTC external clock base on board configuration. */
- void BOARD_InitRtcOsc(void)
- {
- #if ((OSC0_XTAL_FREQ != 32768U) && (RTC_OSC_ENABLE_CONFIG))
- #error Set RTC_OSC_ENABLE_CONFIG will override OSC0 configuration and OSC0 must be 32k.
- #endif
- rtc_osc_user_config_t rtcOscConfig =
- {
- .freq = RTC_XTAL_FREQ,
- .enableCapacitor2p = RTC_SC2P_ENABLE_CONFIG,
- .enableCapacitor4p = RTC_SC4P_ENABLE_CONFIG,
- .enableCapacitor8p = RTC_SC8P_ENABLE_CONFIG,
- .enableCapacitor16p = RTC_SC16P_ENABLE_CONFIG,
- .enableOsc = RTC_OSC_ENABLE_CONFIG,
- .enableClockOutput = RTC_CLK_OUTPUT_ENABLE_CONFIG,
- };
- CLOCK_SYS_RtcOscInit(0U, &rtcOscConfig);
- }
- /*******************************************************************************
- RTCInit()
- *******************************************************************************/
- #define RTC ((RTC_Type *)RTC_BASE)
- #define RTC_BASE_PTR (RTC)
- void RTCInit(void)
- {
- #if FSL_FEATURE_SIM_OPT_HAS_RTC_CLOCK_OUT_SELECTION
- rtc_datetime_t date =
- {
- .year = 2015U,
- .month = 9U,
- .day = 4U,
- .hour = 12U,
- .minute = 0U,
- .second = 0U,
- };
- /* Enable clock gate to RTC module */
- CLOCK_SYS_EnableRtcClock( 0U);
- if (RCM_HAL_GetSrcStatus(RCM, kRcmPowerOn)) // 判断是否上电复位
- {
- RTC_HAL_Init(RTC_BASE_PTR);
- RTC_HAL_SetDatetime(RTC_BASE_PTR, &date);
- }
- RTC_HAL_Enable(RTC_BASE_PTR);
- #endif
- }
复制代码
|
|