#include <hidef.h>      /* common defines and macros */
#include <mc9s12dp256.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dp256b"


#pragma CODE_SEG DEFAULT
void Init(){
 RTICTL = 0x1F;//Real Time Interrupt Control Register 16*2^10
 //set to 1 ms
 EnableInterrupts;
 DDRB = 0xFF;//Data Direction Register set
 
}


void main(void) {
  /* put your own code here */
  int flag = 0;
  Init();
 
  PORTB = 0x0;   
  for(;;) {
     do{
      
        while((CRGFLG & 0x80)==0);
        CRGFLG = 0x80;
        flag++;
     }while(flag != 1000);
     flag = 0;
     PORTB =~PORTB;
  } /* wait forever */
  /* please make sure that you never leave this function */
}
