智能车制作

标题: 新手求指教 128定时器PIT [打印本页]

作者: Star丶新一    时间: 2012-4-27 10:31
标题: 新手求指教 128定时器PIT

//现象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谢谢

作者: WGQHHH    时间: 2013-8-27 14:32
中断向量啊,可以查到的
作者: guozy205    时间: 2013-9-2 15:09
打开 MC9S12XS128.h文件  就能看到0-120 中断向量及中断号




欢迎光临 智能车制作 (http://dns.znczz.com/) Powered by Discuz! X3.2