?? main.c
字號:
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#inclede <sci1.c>
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
void TransmitT(char *text)
{unsigned char a;
a=SCI0SR1;
while (*text != '\0')
{while (!(SCI0SR1 & 0x80)); /* wait for output buffer empty */
SCI0DRL = *text++;}
}
void IniCOM(void)
{SCI0BDL=163; //6M晶鎮,25M總線
SCI0CR1=0; //無奇偶校驗,1個起始位8個數據位1個停止位
SCI0CR2 = 0x2c; //允許接收中斷
}
void InitialRegs(void)
{
/*---------串口初始化------*/
IniCOM();
/*--------鎖相環初始化-------*/
CLKSEL=0x00; //disable pll;
CLKSEL=0;
CLKSEL_PLLSEL = 0;
PLLCTL_PLLON = 0;
SYNR = 24; //6M晶鎮獲得25M總線
REFDV = 5;
PLLCTL = 192;
PLLCTL_PLLON = 1;
while(!CRGFLG_LOCK);
CLKSEL_PLLSEL = 1;
/*-------------------定時中斷初始化----*/
RTICTL=0x1f; //產生定時中斷
CRGINT_RTIE=1; //允許RTI中斷
asm CLI;
DDRT_DDRT4=1;
DDRB_BIT0=1;
DDRP_DDRP3=1;
}
void main(void) {
InitialRegs();
/* put your own code here */
EnableInterrupts;
for(;;) {
TransmitT("The DG128 is OK\n");
} /* wait forever */
}
#pragma CODE_SEG NON_BANKED
interrupt void RTI_ISR (void) {
static i=0;
//閃爍小燈
i++;
if(i>100)
{
PTT_PTT4=PTP_PTP3;
PORTB_BIT0=~PORTB_BIT0;
PTP_PTP3=~PTP_PTP3;i=0;
}
CRGFLG_RTIF=1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -