一、时钟配置
时钟配置基于与TI提供的F2806x_SsysCtrl文件中的InitSysCtrl()函数类似,本文配置如下
- 采用外部晶振30M
- 系统时钟配置为90M
- 所有外设时钟禁用,为方便阅读或移植,在Asan_Cfg.h文件中采用宏定义的方式进行使能相应时钟
整体初始化过程如下:
除InitPeripheralClocks()函数外,其它可直接调用TI提供的InitSysCtrl()函数,配置为90M的系统时钟,宏定义变量如下
InitPeripheralClocks()函数采用如下形式
void InitPeripheralClocks(void)
{
EALLOW;
// LOSPCP prescale register settings, normally it will be set to default values
SysCtrlRegs.LOSPCP.all = 0x0001; //Lowspeed CLK 45M
// XCLKOUT to SYSCLKOUT ratio. By default XCLKOUT = SYSCLKOUT
//SysCtrlRegs.XCLK.bit.XCLKOUTDIV=2;
// Peripheral clock enables set for the selected peripherals.
// If you are not using a peripheral leave the clock off
// to save on power.
//
// Note: not all peripherals are available on all 2803x derivates.
// Refer to the datasheet for your particular device.
//
// This function is not written to be an example of efficient code.
#if (DSP_SUPPORT_ePWM1 == 1)
SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; // ePWM1