中级会员
- 积分
- 286
- 威望
- 190
- 贡献
- 68
- 兑换币
- 0
- 注册时间
- 2012-2-24
- 在线时间
- 14 小时
- 毕业学校
- 安徽工业大学
|
//现象B灯闪动,周期是INTVERAL*(0.01)ms,可用来记时.
//demo by whut_wj
#include <hidef.h> /* common defines and macros */
#include <MC9S12XS128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12xs128"
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 66 PIT0Interrupt(void)
{
PORTB=~PORTB;
PITTF=0x01;
}
#define INTVERAL 100
void SetBusClock(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); //BUS CLOCK=24M
_asm(nop);
while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
CLKSEL_PLLSEL =1; //engage PLL to system;
}
void PitInit(void)
{
PITMTLD0 = 199; //设定8-bit MICRO Timer0寄存器,它每次从199降到0,花费时间为200*0.125us=25us
PITCFLMT|= 0x83; /*0x83=1(PITE)000 0011(PFLMT[1:0])ITE:使能PITPFLMT强制加载8位计数器值*/
PITMUX &= 0xfe; /*定时器0对应8位计数器0*/
PITLD0 =15999;//定时周期=(15999+1)*25us=400ms
PITINTE|= 0x01; /*使能定时器0的time-out中断*/
PITFLT |=0x01; //强制加载
PITCE |= 0x01; /*使能定时器0,开始定时*/
}
void main(void)
{
EnableInterrupts;
SetBusClock();
for(;;)
{
PitInit();
DDRB=0xff;
PIT0Interrupt();
}
}
红色的两行什么意思???void interrupt 66 PIT0Interrupt(void)
为什么是66???O(∩_∩)O谢谢
|
|