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

int flag = 0;

#pragma CODE_SEG __NEAR_SEG NON_BANKED
interrupt void RTI_ISR(void){
 flag++;
 if(flag==1000){
  
    PORTB =~PORTB;    //change to 1 second
    flag=0;
 }

 CRGFLG = 0x80;
}



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


void main(void) {
  /* put your own code here */

  Init();
 
  PORTB = 0x55;   
  for(;;) {
  
  } /* wait forever */
  /* please make sure that you never leave this function */
}
