📄 main.c
字号:
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
void main(void)
{
/* put your own code here */
/********PLL make 8M to 24M********************************/
/* CLKSEL=0; //system clocks are from OSCCLK
PLLCTL_PLLON=1; //turn on pll
SYNR=23;
REFDV=15; //pllclk=2*osc*(SYNR+1)/(REFDV+1)=2*8*24/16= 24 MHz
while(CRGFLG_LOCK==0); //wait untile pll is steady
CLKSEL_PLLSEL=1; //system clocks are from PLLCLK */
/*********************************************************/
/*****实时中断。默认8M总线频率**********************/
RTICTL=0x7f; //RTR[6:4]=111, RTR[3:0]=1111
//溢出周期T=1/(foscclk/1024/64)*(16)= 0.131(s)
CRGFLG=0;
CRGINT_RTIE=1; //enabel Real-time-Interrupt
/****************************************************/
EnableInterrupts;
PORTK=0XFF;
for(;;)
{
//加入工作代码
} /* wait forever */
/* please make sure that you never leave this function */
}
/**********中断服务程序***********************************/
#pragma CODE_SEG __NEAR_SEG NON_BANKED
interrupt 7 void RTI_ISR(void)
{
CRGFLG_RTIF=1; //清除实时中断标志
DDRK= 0XFF;
PORTK_BIT0=~PORTK_BIT0; //点亮或熄灭小灯。显示。
//可在此加入标志,用以完成指定工作
}
/**********中断服务程序***********************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -