#include <hidef.h> /* common defines and macros */
#include <MC9S12XEP100.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12xep100"
#include "CRG_Init.h"
#include "PIT_Init.h"
unsigned char Flag;
void Delay(unsigned int Time)
{
unsigned char i;
for(i=0; i<125; i++)
for( ; Time>0; Time--);
}
void main(void) {
/* put your own code here */
EnableInterrupts;
DDRB=0xff;
PORTB=0xff;
for(;;) {
if(Flag==1){
Flag=0;
Delay(50000);
PORTB_PB0=~PORTB_PB0;
}
} /* wait forever */
/* please make sure that you never leave this function */
}
#pragma CODE_SEG NON_BANKED
interrupt void PIT0_Timeout() //interrupt function when Time0 out 20ms
{
PITTF &= 0x01; // Clear the timer0-out flag
Flag = 1;
}作者: strongchen 时间: 2009-11-16 15:08