TMS320F28374S: 时钟配置

Part Number: TMS320F28374S

F28374S 系统频率 200MHz,我在建立自己的工程,测试定时器时发现周期不对:


//
// Configure CPU-Timer 0, 1, and 2 to interrupt every second:
// 1ms second Period (in uSeconds)
//
configCPUTimer(CPUTIMER0_BASE, DEVICE_SYSCLK_FREQ, 1000);
configCPUTimer(CPUTIMER1_BASE, DEVICE_SYSCLK_FREQ, 1000);
configCPUTimer(CPUTIMER2_BASE, DEVICE_SYSCLK_FREQ, 1000);

以上配置实际测试周期为 20ms。更改参数 DEVICE_SYSCLK_FREQ = 10000000:


configCPUTimer(CPUTIMER0_BASE, 10000000, 1000);
configCPUTimer(CPUTIMER1_BASE, 10000000, 1000);
configCPUTimer(CPUTIMER2_BASE, 10000000, 1000);

此时周期正常。

检测时钟配置发现 Device_init() 中与官方例程状态不同:

#ifdef CPU1

//
// Configure Analog Trim in case of untrimmed or TMX sample
//
if((SysCtl_getDeviceParametric(SYSCTL_DEVICE_QUAL) == 0x0U) &&
(HWREGH(ANALOGSUBSYS_BASE + ASYSCTL_O_ANAREFTRIMA) == 0x0U))
{
Device_configureTMXAnalogTrim();
}

//
// Set up PLL control and clock dividers
//
SysCtl_setClock(DEVICE_SETCLOCK_CFG);

//
// Make sure the LSPCLK divider is set to the default (divide by 4)
//
SysCtl_setLowSpeedClock(SYSCTL_LSPCLK_PRESCALE_4);

//
// These asserts will check that the #defines for the clock rates in
// device.h match the actual rates that have been configured. If they do
// not match, check that the calculations of DEVICE_SYSCLK_FREQ and
// DEVICE_LSPCLK_FREQ are accurate. Some examples will not perform as
// expected if these are not correct.
//
ASSERT(SysCtl_getClock(DEVICE_OSCSRC_FREQ) == DEVICE_SYSCLK_FREQ);
ASSERT(SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ) == DEVICE_LSPCLK_FREQ);

#ifndef _FLASH
//
// Call Device_cal function when run using debugger
// This function is called as part of the Boot code. The function is called
// in the Device_init function since during debug time resets, the boot code
// will not be executed and the gel script will reinitialize all the
// registers and the calibrated values will be lost.
// Sysctl_deviceCal is a wrapper function for Device_Cal
//
SysCtl_deviceCal();
#endif

以上程序被注释掉了,我不知道 #ifdef CPU1 怎么解决。