#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
void Mcu_InitClock(void)
{
CPMUPROT_PROT = 0U; /*不对时钟配置寄存器进行保护*/
CPMUCLKS_PLLSEL = 1U; /*fbus = fpll/2*/
CPMUCLKS_PSTP = 0U; /*伪睡眠时时钟源停止*/
CPMUCLKS_COPOSCSEL1 = 0U;
CPMUCLKS_COPOSCSEL0 = 0U;/*选择内部1MHZ时钟*/
CPMUCLKS_PRE = 0U; /*RTI时钟在伪睡眠时停止*/
CPMUCLKS_PCE = 0U; /*COP时钟在伪睡眠时停止*/
CPMUCLKS_RTIOSCSEL = 0U; /*选择RTI时钟源为内部时钟*/
CPMUSYNR_VCOFRQ = 0x01U; /*48MHZ<fvco<50MHZ */
CPMUSYNR_SYNDIV = 0x18U; /*PLL倍频24+1=25倍*/
CPMUPOSTDIV_POSTDIV = 0U;
CPMUPLL_FM = 0U; /*FM OFF*/
while(CPMU标志寄存器_LOCK == 0U)
{
/* Wait until the PLL is within the desired tolerance of the target frequency */
}
CPMUPROT_PROT = 10U; /*对时钟配置寄存器进行保护*/
CPMUCOP_WCOP = 0U; /*WDG为普通模式,非窗口模式*/
CPMUCOP_RSBCK = 1U; /*BDM调试时RTI和COP时钟停止*/
CPMUCOP_WRTMASK = 1U;
CPMUCOP_CR = 0U;
}
#pragma CODE_SEG NON_BANKED
interrupt VectorNumber_Vrti void ISR_RTI(void)
{
unsigned char i = 0;
i++;
if(i >= 1) {
PT0AD_PT0AD3 = 0;
i = 0;
}
asm("NOP");
}
#pragma CODE_SEG DEFAULT |