#include <hidef.h>
#include "derivative.h"
void Init_Port()
{
// PTA偼慡晹瞻晦奐曻(偲傝偁偊偢慡诉萏哔悲踢)
  PTAD  = 0x00;
  PTADD = 0x00;
  PTAPE = 0xff;
  PTASE = 0x00;
  PTADS = 0x00;

// PTB
// PB[0]:---
// PB[1]:ResetSwitch
// PB[2]:BKGD
// PB[3]:BLMS讲/LED
// PB[4]:XTAL(12MHz)
// PB[5]=>XTAL(12MHz)
// PB[6]=> N/A
// PB[7]=> N/A
  PTBD  = 0x08;
  PTBDD = 0x08;
  PTBPE = 0x03;
  PTBSE = 0x00;
  PTBDS = 0x00;
}


void delay()
{
  unsigned int i,j,k;
  for(k=0;k<20;k++) {
    for (i=0; i<100; i++) {
      for (j=0; j<100; j++)
        ;
    }
  }
}

void main(void) {
 unsigned char c;
 SOPT1 = 0x13; // WDT掆巭.PB1傪鼐擖椡
  // Init_Clock()
 Init_Port();
 c = 0;
 for (;;) {
  if (c & 1) {
    PTBD |= 0x08;
    } else {
      PTBD &= ~0x08;
    }
    c++;
    delay();
  }
}
