中级会员
- 积分
- 445
- 威望
- 280
- 贡献
- 55
- 兑换币
- 0
- 注册时间
- 2009-4-3
- 在线时间
- 55 小时
|
1贡献
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
unsigned char Pulsecnt;
/************************pllclock=48MHz*******************************/
void SET_PLL(void)
{
CLKSEL=0X00; //disengage PLL to system
PLLCTL_PLLON=1; //turn on PLL
SYNR=2;
REFDV=1; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=48MHz;
_asm(nop); //If PLL is selected (PLLSEL=1), Bus Clock = PLLCLK / 2=24MHz
while(CRGFLG_LOCK!=1)
_asm(nop); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
/***************************main()*********************************/
void main(void)
{
/* put your own code here */
SET_PLL();
DDRB=0x00;
PORTB=0xff;
asm sei;
TIOS=0x00;
TSCR1=0x80;
TSCR2=0x01;
TCTL4=0x01;
TIE=0x01;
TFLG1=0x01;
Pulsecnt=0x00;
asm cli;
for(;;) {} /* wait forever */
}
#pragma CODE_SEG NON_BANKED
void interrupt 8 IC0_ISR(void)
{
TFLG1=0x01;
Pulsecnt++;
if(Pulsecnt==255)
Pulsecnt=0;
for(;;) PORTB=0x00; //说明进入中断
}
一次中断都无法进入``` |
|