#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */


void Init(){
    //configurare procesor
    SOPT  = 0x00;	 /* Disable COP	*/
    ICGC2  = 0X00;       // Set up ICG control register 2
    ICGC1  = 0X78;       // Set up ICG for FEE, 4MHz external crystal, busclk = 8MHz
    
	//asteptare pornire FLL (LOCK = 1)
	while(!(ICGS1 & 0x08));   
 
	// configurare PORT F   
    PTFDD = 0xFF;	 

	//configurare seriala 1
    SCI1BD = 8000000/16/19200;
    SCI1C1 = 0;
    SCI1C2 = 0x2C;
}
 
 //rutina intrerupere receptie seriala
interrupt 17 void SCI1_receive()
{
    unsigned char rc;
    rc = SCI1S1;
    PTFD = SCI1D;
} 

void main(void) {
  Init();
  EnableInterrupts; /* enable interrupts */
  /* include your code here */

  PTFD  = 0x00;      

  for(;;) {
  } /* loop forever */
  /* please make sure that you never leave main */
}
