主题中讨论的其他器件:LAUNCHXL-F28379D、 TMDSCNCD28379D、 C2000WARE
各位专家、您好!
我们一直在开发 LAUNCHXL-F28379D 和 TMDSCNCD28379D 控制卡以进行所有开发。 LaunchPad 使用10MHz 晶体、而控制卡使用20MHz 晶体。
我们现在计划将20MHz 单端时钟用于生产件。
通过查看一些 C2000WARE driverlib 示例、我们可以看到以下内容:
在 device.c 中、我们有用于设置 PLL 的'SysCtl_setClock()'函数
//
// Set up PLL control and clock dividers
//
SysCtl_setClock(DEVICE_SETCLOCK_CFG);
在 device.h 中定义了 DEVICE_setClock_CFG
//*****************************************************************************
//
// Defines related to clock configuration
//
//*****************************************************************************
//
// Launchpad Configuration
//
#ifdef _LAUNCHXL_F28379D
//
// 10MHz XTAL on LaunchPad. For use with SysCtl_getClock().
//
#define DEVICE_OSCSRC_FREQ 10000000U
//
// Define to pass to SysCtl_setClock(). Will configure the clock as follows:
// PLLSYSCLK = 10MHz (XTAL_OSC) * 40 (IMULT) * 1 (FMULT) / 2 (PLLCLK_BY_2)
//
#define DEVICE_SETCLOCK_CFG (SYSCTL_OSCSRC_XTAL | SYSCTL_IMULT(40) | \
SYSCTL_FMULT_NONE | SYSCTL_SYSDIV(2) | \
SYSCTL_PLL_ENABLE)
//
// 200MHz SYSCLK frequency based on the above DEVICE_SETCLOCK_CFG. Update the
// code below if a different clock configuration is used!
//
#define DEVICE_SYSCLK_FREQ ((DEVICE_OSCSRC_FREQ * 40 * 1) / 2)
//
// ControlCARD Configuration
//
#else
//
// 20MHz XTAL on controlCARD. For use with SysCtl_getClock().
//
#define DEVICE_OSCSRC_FREQ 20000000U
//
// Define to pass to SysCtl_setClock(). Will configure the clock as follows:
// PLLSYSCLK = 20MHz (XTAL_OSC) * 20 (IMULT) * 1 (FMULT) / 2 (PLLCLK_BY_2)
//
#define DEVICE_SETCLOCK_CFG (SYSCTL_OSCSRC_XTAL | SYSCTL_IMULT(20) | \
SYSCTL_FMULT_NONE | SYSCTL_SYSDIV(2) | \
SYSCTL_PLL_ENABLE)
//
// 200MHz SYSCLK frequency based on the above DEVICE_SETCLOCK_CFG. Update the
// code below if a different clock configuration is used!
//
#define DEVICE_SYSCLK_FREQ ((DEVICE_OSCSRC_FREQ * 20 * 1) / 2)
#endif
SYSCTL_OSCSRC_XTAL 在'sysctl.h'中定义
// // Oscillator source // // Also used with the SysCtl_selectOscSource(), SysCtl_turnOnOsc(), // and SysCtl_turnOffOsc() functions as the oscSource parameter. // #define SYSCTL_OSCSRC_M 0x00030000U // Mask for OSCSRC value in config #define SYSCTL_OSCSRC_S 16U // Shift for OSCSRC value in config //! Internal oscillator INTOSC2 #define SYSCTL_OSCSRC_OSC2 0x00000000U //! External oscillator (XTAL) in crystal mode #define SYSCTL_OSCSRC_XTAL 0x00010000U //! Internal oscillator INTOSC1 #define SYSCTL_OSCSRC_OSC1 0x00020000U // // Enable/disable PLL // #define SYSCTL_PLL_ENABLE 0x80000000U //!< Enable PLL #define SYSCTL_PLL_DISABLE 0x00000000U //!< Disable PLL
现在 、如果我想使用单端时钟、如果我只添加一个新的#define 并递增掩码、那就足够了:
// // Oscillator source // // Also used with the SysCtl_selectOscSource(), SysCtl_turnOnOsc(), // and SysCtl_turnOffOsc() functions as the oscSource parameter. // #define SYSCTL_OSCSRC_M 0x00040000U // Mask for OSCSRC value in config changed from 0x00030000U to 0x00040000U #define SYSCTL_OSCSRC_S 16U // Shift for OSCSRC value in config //! Internal oscillator INTOSC2 #define SYSCTL_OSCSRC_OSC2 0x00000000U //! External oscillator (XTAL) in crystal mode #define SYSCTL_OSCSRC_XTAL 0x00010000U //! Internal oscillator INTOSC1 #define SYSCTL_OSCSRC_OSC1 0x00020000U #define SYSCTL_OSCSRC_XTAL_S 0x00030000U //Newly added
将 SYSCTL_OSCSRC_XTAL_S 添加到 DEVICE_SETCLOCK_CFG 中:
#define DEVICE_SETCLOCK_CFG (SYSCTL_OSCSRC_XTAL_S | SYSCTL_IMULT(20) | \
SYSCTL_FMULT_NONE | SYSCTL_SYSDIV(2) | \
SYSCTL_PLL_ENABLE)
谢谢!
