对28069芯片选用外部无缘晶振8M,对系统分频配置时,
#define DSP28_DIVSEL 3 // Enable /1 for SYSCLKOUT
#define DSP28_PLLCR 10
void InitSysCtrl()
{
XtalOscSel();
InitPll(DSP28_PLLCR, DSP28_DIVSEL);
InitPeripheralClocks();
InitCpuTimers();
}
void InitCpuTimers(void)
{
// CPU Timer 0
// Initialize address pointers to respective timer registers:
CpuTimer0.RegsAddr = &CpuTimer0Regs;
//Clear interrupt flag
CpuTimer0Regs.TCR.bit.TIF = 0;
//Disable CPU_timer interrupt
CpuTimer0Regs.TCR.bit.TIE = 0;
CpuTimer0Regs.TCR.bit.FREE = 0;
//Stop after the next decrement of the TIMH:TIM (hard stop)
CpuTimer0Regs.TCR.bit.SOFT = 0;
// Initialize timer period to maximum:
CpuTimer0Regs.PRD.all = 0xFFFFFFFF;
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
CpuTimer0Regs.TPR.all = 79; // (80MHz/1MHz-1)
CpuTimer0Regs.TPRH.all = 0;
// Make sure timer is stopped:
CpuTimer0Regs.TCR.bit.TSS = 0;
// Reload all counter register with period value:
CpuTimer0Regs.TCR.bit.TRB = 0;
// Reset interrupt counters:
CpuTimer0.InterruptCount = 0;
}
按照道理,主频应该为80MHZ,CPUtimer0是1M,但实测后,发现主频是50Mhz
Eric Ma:ERIC:
建议你查看一下PLLCR和PLLSTS[DIVSEL]对应的寄存器有没有配置成对应的值。
对28069芯片选用外部无缘晶振8M,对系统分频配置时,
#define DSP28_DIVSEL 3 // Enable /1 for SYSCLKOUT
#define DSP28_PLLCR 10
void InitSysCtrl()
{
XtalOscSel();
InitPll(DSP28_PLLCR, DSP28_DIVSEL);
InitPeripheralClocks();
InitCpuTimers();
}
void InitCpuTimers(void)
{
// CPU Timer 0
// Initialize address pointers to respective timer registers:
CpuTimer0.RegsAddr = &CpuTimer0Regs;
//Clear interrupt flag
CpuTimer0Regs.TCR.bit.TIF = 0;
//Disable CPU_timer interrupt
CpuTimer0Regs.TCR.bit.TIE = 0;
CpuTimer0Regs.TCR.bit.FREE = 0;
//Stop after the next decrement of the TIMH:TIM (hard stop)
CpuTimer0Regs.TCR.bit.SOFT = 0;
// Initialize timer period to maximum:
CpuTimer0Regs.PRD.all = 0xFFFFFFFF;
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
CpuTimer0Regs.TPR.all = 79; // (80MHz/1MHz-1)
CpuTimer0Regs.TPRH.all = 0;
// Make sure timer is stopped:
CpuTimer0Regs.TCR.bit.TSS = 0;
// Reload all counter register with period value:
CpuTimer0Regs.TCR.bit.TRB = 0;
// Reset interrupt counters:
CpuTimer0.InterruptCount = 0;
}
按照道理,主频应该为80MHZ,CPUtimer0是1M,但实测后,发现主频是50Mhz
user5130167:
回复 Eric Ma:
谢谢回复,可我的外部无源晶振是8M的,倍频选择为10,分频选择为3(不分频),无论如何都不应该是50M的主频啊…
对28069芯片选用外部无缘晶振8M,对系统分频配置时,
#define DSP28_DIVSEL 3 // Enable /1 for SYSCLKOUT
#define DSP28_PLLCR 10
void InitSysCtrl()
{
XtalOscSel();
InitPll(DSP28_PLLCR, DSP28_DIVSEL);
InitPeripheralClocks();
InitCpuTimers();
}
void InitCpuTimers(void)
{
// CPU Timer 0
// Initialize address pointers to respective timer registers:
CpuTimer0.RegsAddr = &CpuTimer0Regs;
//Clear interrupt flag
CpuTimer0Regs.TCR.bit.TIF = 0;
//Disable CPU_timer interrupt
CpuTimer0Regs.TCR.bit.TIE = 0;
CpuTimer0Regs.TCR.bit.FREE = 0;
//Stop after the next decrement of the TIMH:TIM (hard stop)
CpuTimer0Regs.TCR.bit.SOFT = 0;
// Initialize timer period to maximum:
CpuTimer0Regs.PRD.all = 0xFFFFFFFF;
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
CpuTimer0Regs.TPR.all = 79; // (80MHz/1MHz-1)
CpuTimer0Regs.TPRH.all = 0;
// Make sure timer is stopped:
CpuTimer0Regs.TCR.bit.TSS = 0;
// Reload all counter register with period value:
CpuTimer0Regs.TCR.bit.TRB = 0;
// Reset interrupt counters:
CpuTimer0.InterruptCount = 0;
}
按照道理,主频应该为80MHZ,CPUtimer0是1M,但实测后,发现主频是50Mhz
Young Hu:
回复 user5130167:
能否配置XCLKOUT引脚,通过引脚看一下实际的频率是多少。
对28069芯片选用外部无缘晶振8M,对系统分频配置时,
#define DSP28_DIVSEL 3 // Enable /1 for SYSCLKOUT
#define DSP28_PLLCR 10
void InitSysCtrl()
{
XtalOscSel();
InitPll(DSP28_PLLCR, DSP28_DIVSEL);
InitPeripheralClocks();
InitCpuTimers();
}
void InitCpuTimers(void)
{
// CPU Timer 0
// Initialize address pointers to respective timer registers:
CpuTimer0.RegsAddr = &CpuTimer0Regs;
//Clear interrupt flag
CpuTimer0Regs.TCR.bit.TIF = 0;
//Disable CPU_timer interrupt
CpuTimer0Regs.TCR.bit.TIE = 0;
CpuTimer0Regs.TCR.bit.FREE = 0;
//Stop after the next decrement of the TIMH:TIM (hard stop)
CpuTimer0Regs.TCR.bit.SOFT = 0;
// Initialize timer period to maximum:
CpuTimer0Regs.PRD.all = 0xFFFFFFFF;
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
CpuTimer0Regs.TPR.all = 79; // (80MHz/1MHz-1)
CpuTimer0Regs.TPRH.all = 0;
// Make sure timer is stopped:
CpuTimer0Regs.TCR.bit.TSS = 0;
// Reload all counter register with period value:
CpuTimer0Regs.TCR.bit.TRB = 0;
// Reset interrupt counters:
CpuTimer0.InterruptCount = 0;
}
按照道理,主频应该为80MHZ,CPUtimer0是1M,但实测后,发现主频是50Mhz
user5130167:
回复 Young Hu:
测试了,确实是50MHZ。
但是也查明问题了,在外部无缘晶振配置时,把DELAY_US(1000)去掉延迟,就可以是8M的外部晶振数据了。
同时,倍频没有问题,分频时不能选择DSP28_DIVSEL = 3,只能等于0/1/2,不能不分频。
所以目前我选择18倍频2分频,72MHZ
void XtalOscSel (void) { EALLOW; SysCtrlRegs.CLKCTL.bit.XTALOSCOFF = 0; // Turn on XTALOSC DELAY_US(1000); // Wait for 1ms while XTAL starts up SysCtrlRegs.CLKCTL.bit.XCLKINOFF = 1; // Turn off XCLKIN SysCtrlRegs.CLKCTL.bit.OSCCLKSRC2SEL = 0; // Switch to external clock SysCtrlRegs.CLKCTL.bit.OSCCLKSRCSEL = 1; // Switch from INTOSC1 to INTOSC2/XCLKIN SysCtrlRegs.CLKCTL.bit.WDCLKSRCSEL = 0; // Clock WatchDog off of INTOSC1 always SysCtrlRegs.CLKCTL.bit.INTOSC2OFF = 1; // Turn off INTOSC2 SysCtrlRegs.CLKCTL.bit.INTOSC1OFF = 0; // Leave INTOSC1 on EDIS;}
对28069芯片选用外部无缘晶振8M,对系统分频配置时,
#define DSP28_DIVSEL 3 // Enable /1 for SYSCLKOUT
#define DSP28_PLLCR 10
void InitSysCtrl()
{
XtalOscSel();
InitPll(DSP28_PLLCR, DSP28_DIVSEL);
InitPeripheralClocks();
InitCpuTimers();
}
void InitCpuTimers(void)
{
// CPU Timer 0
// Initialize address pointers to respective timer registers:
CpuTimer0.RegsAddr = &CpuTimer0Regs;
//Clear interrupt flag
CpuTimer0Regs.TCR.bit.TIF = 0;
//Disable CPU_timer interrupt
CpuTimer0Regs.TCR.bit.TIE = 0;
CpuTimer0Regs.TCR.bit.FREE = 0;
//Stop after the next decrement of the TIMH:TIM (hard stop)
CpuTimer0Regs.TCR.bit.SOFT = 0;
// Initialize timer period to maximum:
CpuTimer0Regs.PRD.all = 0xFFFFFFFF;
// Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
CpuTimer0Regs.TPR.all = 79; // (80MHz/1MHz-1)
CpuTimer0Regs.TPRH.all = 0;
// Make sure timer is stopped:
CpuTimer0Regs.TCR.bit.TSS = 0;
// Reload all counter register with period value:
CpuTimer0Regs.TCR.bit.TRB = 0;
// Reset interrupt counters:
CpuTimer0.InterruptCount = 0;
}
按照道理,主频应该为80MHZ,CPUtimer0是1M,但实测后,发现主频是50Mhz
Young Hu:
回复 user5130167:
MemCopy放在InitSysCtrl之前,也就是main函数进来以后第一句话。用XCLKOUT查看一下有无波形输出。