#include "7040s.h"

char  a[10],b[10];
short c[10],d[10];
int   e[10],f[10];
long  g[10],h[10];

void sci_set(void)
{
  SCI0.SMR.BYTE = 0;
  SCI0.SMR.BIT.CA   = 1;
  SCI0.SMR.BIT.CHR  = 1;
/* #undef PE              */
/* SCI0.SMR.BIT.PE   = 1; */
  SCI0.SMR.BIT.OE   = 1;
  SCI0.SMR.BIT.STOP = 1;
  SCI0.SMR.BIT.MP   = 1;
  SCI0.SMR.BIT.CKS  = 3;
  SCI0.BRR = 0;
  SCI0.SCR.BYTE = 0;
  SCI0.SCR.BIT.TIE  = 1;
  SCI0.SCR.BIT.RIE  = 1;
  SCI0.SCR.BIT.TE   = 1;
  SCI0.SCR.BIT.RE   = 1;
  SCI0.SCR.BIT.MPIE = 1;
  SCI0.SCR.BIT.TEIE = 1;
  SCI0.SCR.BIT.CKE  = 3;
  SCI0.TDR = 0;
  SCI0.SSR.BYTE = 0;
  SCI0.SSR.BIT.TDRE = 1;
  SCI0.SSR.BIT.RDRF = 1;
  SCI0.SSR.BIT.ORER = 1;
  SCI0.SSR.BIT.FER  = 1;
  SCI0.SSR.BIT.PER  = 1;
  SCI0.SSR.BIT.TEND = 1;
  SCI0.SSR.BIT.MPB  = 1;
  SCI0.SSR.BIT.MPBT = 1;
  SCI0.RDR = 0;

  SCI1.SMR.BYTE = 0;
  SCI1.SMR.BIT.CA   = 1;
  SCI1.SMR.BIT.CHR  = 1;
/* #undef PE              */
/* SCI1.SMR.BIT.PE   = 1; */
  SCI1.SMR.BIT.OE   = 1;
  SCI1.SMR.BIT.STOP = 1;
  SCI1.SMR.BIT.MP   = 1;
  SCI1.SMR.BIT.CKS  = 3;
  SCI1.BRR = 0;
  SCI1.SCR.BYTE = 0;
  SCI1.SCR.BIT.TIE  = 1;
  SCI1.SCR.BIT.RIE  = 1;
  SCI1.SCR.BIT.TE   = 1;
  SCI1.SCR.BIT.RE   = 1;
  SCI1.SCR.BIT.MPIE = 1;
  SCI1.SCR.BIT.TEIE = 1;
  SCI1.SCR.BIT.CKE  = 3;
  SCI1.TDR = 0;
  SCI1.SSR.BYTE = 0;
  SCI1.SSR.BIT.TDRE = 1;
  SCI1.SSR.BIT.RDRF = 1;
  SCI1.SSR.BIT.ORER = 1;
  SCI1.SSR.BIT.FER  = 1;
  SCI1.SSR.BIT.PER  = 1;
  SCI1.SSR.BIT.TEND = 1;
  SCI1.SSR.BIT.MPB  = 1;
  SCI1.SSR.BIT.MPBT = 1;
  SCI1.RDR = 0;
}

void mtu_set(void)
{
  MTU.TSTR.BYTE = 0;
  MTU.TSTR.BIT.CST4 = 1;
  MTU.TSTR.BIT.CST3 = 1;
  MTU.TSTR.BIT.CST2 = 1;
  MTU.TSTR.BIT.CST1 = 1;
  MTU.TSTR.BIT.CST0 = 1;
  MTU.TSYR.BYTE = 0;
  MTU.TSYR.BIT.SYNC4 = 1;
  MTU.TSYR.BIT.SYNC3 = 1;
  MTU.TSYR.BIT.SYNC2 = 1;
  MTU.TSYR.BIT.SYNC1 = 1;
  MTU.TSYR.BIT.SYNC0 = 1;

  MTU0.TCR.BYTE = 0;
  MTU0.TCR.BIT.CCLR = 7;
  MTU0.TCR.BIT.CKEG = 3;
  MTU0.TCR.BIT.TPSC = 7;
  MTU0.TMDR.BYTE = 0;
  MTU0.TMDR.BIT.BFB = 1;
  MTU0.TMDR.BIT.BFA = 1;
  MTU0.TMDR.BIT.MD  = 15;
  MTU0.TIOR.WORD = 0;
  MTU0.TIOR.BYTE.H = 0;
  MTU0.TIOR.BYTE.L = 0;
  MTU0.TIOR.BIT.IOB = 15;
  MTU0.TIOR.BIT.IOA = 15;
  MTU0.TIOR.BIT.IOD = 15;
  MTU0.TIOR.BIT.IOC = 15;
  MTU0.TIER.BYTE = 0;
  MTU0.TIER.BIT.TTGE  = 1;
  MTU0.TIER.BIT.TCIEV = 1;
  MTU0.TIER.BIT.TGIED = 1;
  MTU0.TIER.BIT.TGIEC = 1;
  MTU0.TIER.BIT.TGIEB = 1;
  MTU0.TIER.BIT.TGIEA = 1;
  MTU0.TSR.BYTE = 0;
  MTU0.TSR.BIT.TCFV = 1;
  MTU0.TSR.BIT.TGFD = 1;
  MTU0.TSR.BIT.TGFC = 1;
  MTU0.TSR.BIT.TGFB = 1;
  MTU0.TSR.BIT.TGFA = 1;
  MTU0.TCNT = 0;
  MTU0.TGRA = 0;
  MTU0.TGRB = 0;
  MTU0.TGRC = 0;
  MTU0.TGRD = 0;

  MTU1.TCR.BYTE = 0;
  MTU1.TCR.BIT.CCLR = 3;
  MTU1.TCR.BIT.CKEG = 3;
  MTU1.TCR.BIT.TPSC = 7;
  MTU1.TMDR.BYTE = 0;
  MTU1.TMDR.BIT.MD  = 15;
  MTU1.TIOR.BYTE = 0;
  MTU1.TIOR.BIT.IOB = 15;
  MTU1.TIOR.BIT.IOA = 15;
  MTU1.TIER.BYTE = 0;
  MTU1.TIER.BIT.TTGE  = 1;
  MTU1.TIER.BIT.TCIEU = 1;
  MTU1.TIER.BIT.TCIEV = 1;
  MTU1.TIER.BIT.TGIEB = 1;
  MTU1.TIER.BIT.TGIEA = 1;
  MTU1.TSR.BYTE = 0;
  MTU1.TSR.BIT.TCFD = 1;
  MTU1.TSR.BIT.TCFU = 1;
  MTU1.TSR.BIT.TCFV = 1;
  MTU1.TSR.BIT.TGFB = 1;
  MTU1.TSR.BIT.TGFA = 1;
  MTU1.TCNT = 0;
  MTU1.TGRA = 0;
  MTU1.TGRB = 0;

  MTU2.TCR.BYTE = 0;
  MTU2.TCR.BIT.CCLR = 3;
  MTU2.TCR.BIT.CKEG = 3;
  MTU2.TCR.BIT.TPSC = 7;
  MTU2.TMDR.BYTE = 0;
  MTU2.TMDR.BIT.MD  = 15;
  MTU2.TIOR.BYTE = 0;
  MTU2.TIOR.BIT.IOB = 15;
  MTU2.TIOR.BIT.IOA = 15;
  MTU2.TIER.BYTE = 0;
  MTU2.TIER.BIT.TTGE  = 1;
  MTU2.TIER.BIT.TCIEU = 1;
  MTU2.TIER.BIT.TCIEV = 1;
  MTU2.TIER.BIT.TGIEB = 1;
  MTU2.TIER.BIT.TGIEA = 1;
  MTU2.TSR.BYTE = 0;
  MTU2.TSR.BIT.TCFD = 1;
  MTU2.TSR.BIT.TCFU = 1;
  MTU2.TSR.BIT.TCFV = 1;
  MTU2.TSR.BIT.TGFB = 1;
  MTU2.TSR.BIT.TGFA = 1;
  MTU2.TCNT = 0;
  MTU2.TGRA = 0;
  MTU2.TGRB = 0;

  MTU3.TCR.BYTE = 0;
  MTU3.TCR.BIT.CCLR = 7;
  MTU3.TCR.BIT.CKEG = 3;
  MTU3.TCR.BIT.TPSC = 7;
  MTU3.TMDR.BYTE = 0;
  MTU3.TMDR.BIT.BFB = 1;
  MTU3.TMDR.BIT.BFA = 1;
  MTU3.TMDR.BIT.MD  = 15;
  MTU3.TIOR.WORD = 0;
  MTU3.TIOR.BYTE.H = 0;
  MTU3.TIOR.BYTE.L = 0;
  MTU3.TIOR.BIT.IOB = 15;
  MTU3.TIOR.BIT.IOA = 15;
  MTU3.TIOR.BIT.IOD = 15;
  MTU3.TIOR.BIT.IOC = 15;
  MTU3.TIER.BYTE = 0;
  MTU3.TIER.BIT.TTGE  = 1;
  MTU3.TIER.BIT.TCIEV = 1;
  MTU3.TIER.BIT.TGIED = 1;
  MTU3.TIER.BIT.TGIEC = 1;
  MTU3.TIER.BIT.TGIEB = 1;
  MTU3.TIER.BIT.TGIEA = 1;
  MTU3.TSR.BYTE = 0;
  MTU3.TSR.BIT.TCFD = 1;
  MTU3.TSR.BIT.TCFV = 1;
  MTU3.TSR.BIT.TGFD = 1;
  MTU3.TSR.BIT.TGFC = 1;
  MTU3.TSR.BIT.TGFB = 1;
  MTU3.TSR.BIT.TGFA = 1;
  MTU3.TCNT = 0;
  MTU3.TGRA = 0;
  MTU3.TGRB = 0;
  MTU3.TGRC = 0;
  MTU3.TGRD = 0;

  MTU4.TCR.BYTE = 0;
  MTU4.TCR.BIT.CCLR = 7;
  MTU4.TCR.BIT.CKEG = 3;
  MTU4.TCR.BIT.TPSC = 7;
  MTU4.TMDR.BYTE = 0;
  MTU4.TMDR.BIT.BFB = 1;
  MTU4.TMDR.BIT.BFA = 1;
  MTU4.TMDR.BIT.MD  = 15;
  MTU4.TIOR.WORD = 0;
  MTU4.TIOR.BYTE.H = 0;
  MTU4.TIOR.BYTE.L = 0;
  MTU4.TIOR.BIT.IOB = 15;
  MTU4.TIOR.BIT.IOA = 15;
  MTU4.TIOR.BIT.IOD = 15;
  MTU4.TIOR.BIT.IOC = 15;
  MTU4.TIER.BYTE = 0;
  MTU4.TIER.BIT.TTGE  = 1;
  MTU4.TIER.BIT.TCIEV = 1;
  MTU4.TIER.BIT.TGIED = 1;
  MTU4.TIER.BIT.TGIEC = 1;
  MTU4.TIER.BIT.TGIEB = 1;
  MTU4.TIER.BIT.TGIEA = 1;
  MTU4.TSR.BYTE = 0;
  MTU4.TSR.BIT.TCFD = 1;
  MTU4.TSR.BIT.TCFV = 1;
  MTU4.TSR.BIT.TGFD = 1;
  MTU4.TSR.BIT.TGFC = 1;
  MTU4.TSR.BIT.TGFB = 1;
  MTU4.TSR.BIT.TGFA = 1;
  MTU4.TCNT = 0;
  MTU4.TGRA = 0;
  MTU4.TGRB = 0;
  MTU4.TGRC = 0;
  MTU4.TGRD = 0;
}

void pwm_set(void)
{
/* MTU3 and MTU4 used PWM Mode */
  PWM.TCR3.BYTE = 0;
  PWM.TCR3.BIT.CCLR = 7;
  PWM.TCR3.BIT.CKEG = 3;
  PWM.TCR3.BIT.TPSC = 7;
  PWM.TMDR3.BYTE = 0;
  PWM.TMDR3.BIT.BFB = 1;
  PWM.TMDR3.BIT.BFA = 1;
  PWM.TMDR3.BIT.MD  = 15;
  PWM.TIOR3.WORD = 0;
  PWM.TIOR3.BYTE.H = 0;
  PWM.TIOR3.BYTE.L = 0;
  PWM.TIOR3.BIT.IOB = 15;
  PWM.TIOR3.BIT.IOA = 15;
  PWM.TIOR3.BIT.IOD = 15;
  PWM.TIOR3.BIT.IOC = 15;
  PWM.TIER3.BYTE = 0;
  PWM.TIER3.BIT.TTGE  = 1;
  PWM.TIER3.BIT.TCIEV = 1;
  PWM.TIER3.BIT.TGIED = 1;
  PWM.TIER3.BIT.TGIEC = 1;
  PWM.TIER3.BIT.TGIEB = 1;
  PWM.TIER3.BIT.TGIEA = 1;
  PWM.TSR3.BYTE = 0;
  PWM.TSR3.BIT.TCFD = 1;
  PWM.TSR3.BIT.TCFV = 1;
  PWM.TSR3.BIT.TGFD = 1;
  PWM.TSR3.BIT.TGFC = 1;
  PWM.TSR3.BIT.TGFB = 1;
  PWM.TSR3.BIT.TGFA = 1;
  PWM.TCNT3 = 0;
  PWM.TGR3A = 0;
  PWM.TGR3B = 0;
  PWM.TGR3C = 0;
  PWM.TGR3D = 0;
  PWM.TCR4.BYTE = 0;
  PWM.TCR4.BIT.CCLR = 7;
  PWM.TCR4.BIT.CKEG = 3;
  PWM.TCR4.BIT.TPSC = 7;
  PWM.TMDR4.BYTE = 0;
  PWM.TMDR4.BIT.BFB = 1;
  PWM.TMDR4.BIT.BFA = 1;
  PWM.TMDR4.BIT.MD  = 15;
  PWM.TIOR4.WORD = 0;
  PWM.TIOR4.BYTE.H = 0;
  PWM.TIOR4.BYTE.L = 0;
  PWM.TIOR4.BIT.IOB = 15;
  PWM.TIOR4.BIT.IOA = 15;
  PWM.TIOR4.BIT.IOD = 15;
  PWM.TIOR4.BIT.IOC = 15;
  PWM.TIER4.BYTE = 0;
  PWM.TIER4.BIT.TTGE  = 1;
  PWM.TIER4.BIT.TCIEV = 1;
  PWM.TIER4.BIT.TGIED = 1;
  PWM.TIER4.BIT.TGIEC = 1;
  PWM.TIER4.BIT.TGIEB = 1;
  PWM.TIER4.BIT.TGIEA = 1;
  PWM.TSR4.BYTE = 0;
  PWM.TSR4.BIT.TCFD = 1;
  PWM.TSR4.BIT.TCFV = 1;
  PWM.TSR4.BIT.TGFD = 1;
  PWM.TSR4.BIT.TGFC = 1;
  PWM.TSR4.BIT.TGFB = 1;
  PWM.TSR4.BIT.TGFA = 1;
  PWM.TCNT4 = 0;
  PWM.TGR4A = 0;
  PWM.TGR4B = 0;
  PWM.TGR4C = 0;
  PWM.TGR4D = 0;
  PWM.TOER.BYTE = 0;
  PWM.TOER.BIT.OE4D = 1;
  PWM.TOER.BIT.OE4C = 1;
  PWM.TOER.BIT.OE3D = 1;
  PWM.TOER.BIT.OE4B = 1;
  PWM.TOER.BIT.OE4A = 1;
  PWM.TOER.BIT.OE3B = 1;
  PWM.TOCR.BYTE = 0;
  PWM.TOCR.BIT.PSYE = 1;
  PWM.TOCR.BIT.OLSN = 1;
  PWM.TOCR.BIT.OLSP = 1;
  PWM.TGCR.BYTE = 0;
  PWM.TGCR.BIT.BDC = 1;
  PWM.TGCR.BIT.N   = 1;
  PWM.TGCR.BIT.P   = 1;
  PWM.TGCR.BIT.FB  = 1;
  PWM.TGCR.BIT.WF  = 1;
  PWM.TGCR.BIT.VF  = 1;
  PWM.TGCR.BIT.UF  = 1;
  PWM.TCDR = 0;
  PWM.TDDR = 0;
  PWM.TCNTS =0;
  PWM.TCBR = 0;
}

void intc_set(void)
{
  INTC.IPRA.WORD = 0;
  INTC.IPRA.BIT.UU = 15;  /* Set IRQ0    Interrupt Level */
  INTC.IPRA.BIT.UL = 15;  /* Set IRQ1    Interrupt Level */
  INTC.IPRA.BIT.LU = 15;  /* Set IRQ2    Interrupt Level */
  INTC.IPRA.BIT.LL = 15;  /* Set IRQ3    Interrupt Level */
  INTC.IPRB.WORD = 0;
  INTC.IPRB.BIT.UU = 15;  /* Set IRQ4    Interrupt Level */
  INTC.IPRB.BIT.UL = 15;  /* Set IRQ5    Interrupt Level */
  INTC.IPRB.BIT.LU = 15;  /* Set IRQ6    Interrupt Level */
  INTC.IPRB.BIT.LL = 15;  /* Set IRQ7    Interrupt Level */
  INTC.IPRC.WORD = 0;
  INTC.IPRC.BIT.UU = 15;  /* Set DMAC0   Interrupt Level */
  INTC.IPRC.BIT.UL = 15;  /* Set DMAC1   Interrupt Level */
  INTC.IPRC.BIT.LU = 15;  /* Set DMAC2   Interrupt Level */
  INTC.IPRC.BIT.LL = 15;  /* Set DMAC3   Interrupt Level */
  INTC.IPRD.WORD = 0;
  INTC.IPRD.BIT.UU = 15;  /* Set MTU0    Interrupt Level */
  INTC.IPRD.BIT.UL = 15;  /* Set MTU0    Interrupt Level */
  INTC.IPRD.BIT.LU = 15;  /* Set MTU1    Interrupt Level */
  INTC.IPRD.BIT.LL = 15;  /* Set MTU1    Interrupt Level */
  INTC.IPRE.WORD = 0;
  INTC.IPRE.BIT.UU = 15;  /* Set MTU2    Interrupt Level */
  INTC.IPRE.BIT.UL = 15;  /* Set MTU2    Interrupt Level */
  INTC.IPRE.BIT.LU = 15;  /* Set MTU3    Interrupt Level */
  INTC.IPRE.BIT.LL = 15;  /* Set MTU3    Interrupt Level */
  INTC.IPRF.WORD = 0;
  INTC.IPRF.BIT.UU = 15;  /* Set MTU4    Interrupt Level */
  INTC.IPRF.BIT.UL = 15;  /* Set MTU4    Interrupt Level */
  INTC.IPRF.BIT.LU = 15;  /* Set SCI0    Interrupt Level */
  INTC.IPRF.BIT.LL = 15;  /* Set SCI1    Interrupt Level */
  INTC.IPRG.WORD = 0;
  INTC.IPRG.BIT.UU = 15;  /* Set A/D     Interrupt Level */
  INTC.IPRG.BIT.UL = 15;  /* Set DTC     Interrupt Level */
  INTC.IPRG.BIT.LU = 15;  /* Set CMT0    Interrupt Level */
  INTC.IPRG.BIT.LL = 15;  /* Set CMT1    Interrupt Level */
  INTC.IPRH.WORD = 0;
  INTC.IPRH.BIT.UU = 15;  /* Set WDT,BSC Interrupt Level */
  INTC.IPRH.BIT.UL = 15;  /* Set I/O     Interrupt Level */
  INTC.ICR.WORD = 0;
  INTC.ICR.BIT.NMIL = 1;
  INTC.ICR.BIT.NMIE = 1;
  INTC.ICR.BIT.IRQ0S = 1;
  INTC.ICR.BIT.IRQ1S = 1;
  INTC.ICR.BIT.IRQ2S = 1;
  INTC.ICR.BIT.IRQ3S = 1;
  INTC.ICR.BIT.IRQ4S = 1;
  INTC.ICR.BIT.IRQ5S = 1;
  INTC.ICR.BIT.IRQ6S = 1;
  INTC.ICR.BIT.IRQ7S = 1;
  INTC.ISR.WORD = 0;
  INTC.ISR.BIT.IRQ0F = 1;
  INTC.ISR.BIT.IRQ1F = 1;
  INTC.ISR.BIT.IRQ2F = 1;
  INTC.ISR.BIT.IRQ3F = 1;
  INTC.ISR.BIT.IRQ4F = 1;
  INTC.ISR.BIT.IRQ5F = 1;
  INTC.ISR.BIT.IRQ6F = 1;
  INTC.ISR.BIT.IRQ7F = 1;
}

void pa_set(void)
{
  PA.DR.LONG = 0;
  PA.DR.WORD.H = 0;
  PA.DR.WORD.L = 0;
  PA.DR.BYTE.HL = 0;
  PA.DR.BYTE.LH = 0;
  PA.DR.BYTE.LL = 0;
  PA.DR.BIT.B23 = 1;
  PA.DR.BIT.B22 = 1;
  PA.DR.BIT.B21 = 1;
  PA.DR.BIT.B20 = 1;
  PA.DR.BIT.B19 = 1;
  PA.DR.BIT.B18 = 1;
  PA.DR.BIT.B17 = 1;
  PA.DR.BIT.B16 = 1;
  PA.DR.BIT.B15 = 1;
  PA.DR.BIT.B14 = 1;
  PA.DR.BIT.B13 = 1;
  PA.DR.BIT.B12 = 1;
  PA.DR.BIT.B11 = 1;
  PA.DR.BIT.B10 = 1;
  PA.DR.BIT.B9  = 1;
  PA.DR.BIT.B8  = 1;
  PA.DR.BIT.B7  = 1;
  PA.DR.BIT.B6  = 1;
  PA.DR.BIT.B5  = 1;
  PA.DR.BIT.B4  = 1;
  PA.DR.BIT.B3  = 1;
  PA.DR.BIT.B2  = 1;
  PA.DR.BIT.B1  = 1;
  PA.DR.BIT.B0  = 1;
}

void pb_set(void)
{
  PB.DR.WORD = 0;
  PB.DR.BYTE.H = 0;
  PB.DR.BYTE.L = 0;
  PB.DR.BIT.B9 = 1;
  PB.DR.BIT.B8 = 1;
  PB.DR.BIT.B7 = 1;
  PB.DR.BIT.B6 = 1;
  PB.DR.BIT.B5 = 1;
  PB.DR.BIT.B4 = 1;
  PB.DR.BIT.B3 = 1;
  PB.DR.BIT.B2 = 1;
  PB.DR.BIT.B1 = 1;
  PB.DR.BIT.B0 = 1;
}

void pc_set(void)
{
  PC.DR.WORD = 0;
  PC.DR.BYTE.H = 0;
  PC.DR.BYTE.L = 0;
  PC.DR.BIT.B15 = 1;
  PC.DR.BIT.B14 = 1;
  PC.DR.BIT.B13 = 1;
  PC.DR.BIT.B12 = 1;
  PC.DR.BIT.B11 = 1;
  PC.DR.BIT.B10 = 1;
  PC.DR.BIT.B9  = 1;
  PC.DR.BIT.B8  = 1;
  PC.DR.BIT.B7  = 1;
  PC.DR.BIT.B6  = 1;
  PC.DR.BIT.B5  = 1;
  PC.DR.BIT.B4  = 1;
  PC.DR.BIT.B3  = 1;
  PC.DR.BIT.B2  = 1;
  PC.DR.BIT.B1  = 1;
  PC.DR.BIT.B0  = 1;
}

void pd_set(void)
{
  PD.DR.LONG = 0;
  PD.DR.WORD.H = 0;
  PD.DR.WORD.L = 0;
  PD.DR.BYTE.HH = 0;
  PD.DR.BYTE.HL = 0;
  PD.DR.BYTE.LH = 0;
  PD.DR.BYTE.LL = 0;
  PD.DR.BIT.B31 = 1;
  PD.DR.BIT.B30 = 1;
  PD.DR.BIT.B29 = 1;
  PD.DR.BIT.B28 = 1;
  PD.DR.BIT.B27 = 1;
  PD.DR.BIT.B26 = 1;
  PD.DR.BIT.B25 = 1;
  PD.DR.BIT.B24 = 1;
  PD.DR.BIT.B23 = 1;
  PD.DR.BIT.B22 = 1;
  PD.DR.BIT.B21 = 1;
  PD.DR.BIT.B20 = 1;
  PD.DR.BIT.B19 = 1;
  PD.DR.BIT.B18 = 1;
  PD.DR.BIT.B17 = 1;
  PD.DR.BIT.B16 = 1;
  PD.DR.BIT.B15 = 1;
  PD.DR.BIT.B14 = 1;
  PD.DR.BIT.B13 = 1;
  PD.DR.BIT.B12 = 1;
  PD.DR.BIT.B11 = 1;
  PD.DR.BIT.B10 = 1;
  PD.DR.BIT.B9  = 1;
  PD.DR.BIT.B8  = 1;
  PD.DR.BIT.B7  = 1;
  PD.DR.BIT.B6  = 1;
  PD.DR.BIT.B5  = 1;
  PD.DR.BIT.B4  = 1;
  PD.DR.BIT.B3  = 1;
  PD.DR.BIT.B2  = 1;
  PD.DR.BIT.B1  = 1;
  PD.DR.BIT.B0  = 1;
}

void pe_set(void)
{
  PE.DR.WORD = 0;
  PE.DR.BYTE.H = 0;
  PE.DR.BYTE.L = 0;
  PE.DR.BIT.B15 = 1;
  PE.DR.BIT.B14 = 1;
  PE.DR.BIT.B13 = 1;
  PE.DR.BIT.B12 = 1;
  PE.DR.BIT.B11 = 1;
  PE.DR.BIT.B10 = 1;
  PE.DR.BIT.B9  = 1;
  PE.DR.BIT.B8  = 1;
  PE.DR.BIT.B7  = 1;
  PE.DR.BIT.B6  = 1;
  PE.DR.BIT.B5  = 1;
  PE.DR.BIT.B4  = 1;
  PE.DR.BIT.B3  = 1;
  PE.DR.BIT.B2  = 1;
  PE.DR.BIT.B1  = 1;
  PE.DR.BIT.B0  = 1;
}

void pf_set(void)
{
  PF.DR.BYTE = 0;
  PF.DR.BIT.B7 = 1;
  PF.DR.BIT.B6 = 1;
  PF.DR.BIT.B5 = 1;
  PF.DR.BIT.B4 = 1;
  PF.DR.BIT.B3 = 1;
  PF.DR.BIT.B2 = 1;
  PF.DR.BIT.B1 = 1;
  PF.DR.BIT.B0 = 1;
}

void pfc_set(void)
{
  PFC.PAIORH.WORD = 0;
  PFC.PAIORH.BIT.B23 = 1;
  PFC.PAIORH.BIT.B22 = 1;
  PFC.PAIORH.BIT.B21 = 1;
  PFC.PAIORH.BIT.B20 = 1;
  PFC.PAIORH.BIT.B19 = 1;
  PFC.PAIORH.BIT.B18 = 1;
  PFC.PAIORH.BIT.B17 = 1;
  PFC.PAIORH.BIT.B16 = 1;
  PFC.PAIORL.WORD = 0;
  PFC.PAIORL.BIT.B15 = 1;
  PFC.PAIORL.BIT.B14 = 1;
  PFC.PAIORL.BIT.B13 = 1;
  PFC.PAIORL.BIT.B12 = 1;
  PFC.PAIORL.BIT.B11 = 1;
  PFC.PAIORL.BIT.B10 = 1;
  PFC.PAIORL.BIT.B9  = 1;
  PFC.PAIORL.BIT.B8  = 1;
  PFC.PAIORL.BIT.B7  = 1;
  PFC.PAIORL.BIT.B6  = 1;
  PFC.PAIORL.BIT.B5  = 1;
  PFC.PAIORL.BIT.B4  = 1;
  PFC.PAIORL.BIT.B3  = 1;
  PFC.PAIORL.BIT.B2  = 1;
  PFC.PAIORL.BIT.B1  = 1;
  PFC.PAIORL.BIT.B0  = 1;
  PFC.PACRH.WORD = 0;
  PFC.PACRH.BIT.MD23 = 1;
  PFC.PACRH.BIT.MD22 = 1;
  PFC.PACRH.BIT.MD21 = 1;
  PFC.PACRH.BIT.MD20 = 1;
  PFC.PACRH.BIT.MD19 = 3;
  PFC.PACRH.BIT.MD18 = 3;
  PFC.PACRH.BIT.MD17 = 1;
  PFC.PACRH.BIT.MD16 = 1;
  PFC.PACRL1.WORD = 0;
  PFC.PACRL1.BIT.MD15 = 1;
  PFC.PACRL1.BIT.MD14 = 1;
  PFC.PACRL1.BIT.MD13 = 1;
  PFC.PACRL1.BIT.MD12 = 1;
  PFC.PACRL1.BIT.MD11 = 1;
  PFC.PACRL1.BIT.MD10 = 1;
  PFC.PACRL1.BIT.MD9  = 3;
  PFC.PACRL1.BIT.MD8  = 3;
  PFC.PACRL2.WORD = 0;
  PFC.PACRL2.BIT.MD7 = 3;
  PFC.PACRL2.BIT.MD6 = 3;
  PFC.PACRL2.BIT.MD5 = 3;
  PFC.PACRL2.BIT.MD4 = 1;
  PFC.PACRL2.BIT.MD3 = 1;
  PFC.PACRL2.BIT.MD2 = 3;
  PFC.PACRL2.BIT.MD1 = 1;
  PFC.PACRL2.BIT.MD0 = 1;
  PFC.PBIOR.WORD = 0;
  PFC.PBIOR.BIT.B9 = 1;
  PFC.PBIOR.BIT.B8 = 1;
  PFC.PBIOR.BIT.B7 = 1;
  PFC.PBIOR.BIT.B6 = 1;
  PFC.PBIOR.BIT.B5 = 1;
  PFC.PBIOR.BIT.B4 = 1;
  PFC.PBIOR.BIT.B3 = 1;
  PFC.PBIOR.BIT.B2 = 1;
  PFC.PBIOR.BIT.B1 = 1;
  PFC.PBIOR.BIT.B0 = 1;
  PFC.PBCR1.WORD = 0;
  PFC.PBCR1.BIT.MD9 = 3;
  PFC.PBCR1.BIT.MD8 = 3;
  PFC.PBCR2.WORD = 0;
  PFC.PBCR2.BIT.MD7 = 3;
  PFC.PBCR2.BIT.MD6 = 3;
  PFC.PBCR2.BIT.MD5 = 3;
  PFC.PBCR2.BIT.MD4 = 3;
  PFC.PBCR2.BIT.MD3 = 3;
  PFC.PBCR2.BIT.MD2 = 3;
  PFC.PBCR2.BIT.MD1 = 1;
  PFC.PBCR2.BIT.MD0 = 1;
  PFC.PCIOR.WORD = 0;
  PFC.PCIOR.BIT.B15 = 1;
  PFC.PCIOR.BIT.B14 = 1;
  PFC.PCIOR.BIT.B13 = 1;
  PFC.PCIOR.BIT.B12 = 1;
  PFC.PCIOR.BIT.B11 = 1;
  PFC.PCIOR.BIT.B10 = 1;
  PFC.PCIOR.BIT.B9  = 1;
  PFC.PCIOR.BIT.B8  = 1;
  PFC.PCIOR.BIT.B7  = 1;
  PFC.PCIOR.BIT.B6  = 1;
  PFC.PCIOR.BIT.B5  = 1;
  PFC.PCIOR.BIT.B4  = 1;
  PFC.PCIOR.BIT.B3  = 1;
  PFC.PCIOR.BIT.B2  = 1;
  PFC.PCIOR.BIT.B1  = 1;
  PFC.PCIOR.BIT.B0  = 1;
  PFC.PCCR.WORD = 0;
  PFC.PCCR.BIT.MD15 = 1;
  PFC.PCCR.BIT.MD14 = 1;
  PFC.PCCR.BIT.MD13 = 1;
  PFC.PCCR.BIT.MD12 = 1;
  PFC.PCCR.BIT.MD11 = 1;
  PFC.PCCR.BIT.MD10 = 1;
  PFC.PCCR.BIT.MD9  = 1;
  PFC.PCCR.BIT.MD8  = 1;
  PFC.PCCR.BIT.MD7  = 1;
  PFC.PCCR.BIT.MD6  = 1;
  PFC.PCCR.BIT.MD5  = 1;
  PFC.PCCR.BIT.MD4  = 1;
  PFC.PCCR.BIT.MD3  = 1;
  PFC.PCCR.BIT.MD2  = 1;
  PFC.PCCR.BIT.MD1  = 1;
  PFC.PCCR.BIT.MD0  = 1;
  PFC.PDIORH.WORD = 0;
  PFC.PDIORH.BIT.B31 = 1;
  PFC.PDIORH.BIT.B30 = 1;
  PFC.PDIORH.BIT.B29 = 1;
  PFC.PDIORH.BIT.B28 = 1;
  PFC.PDIORH.BIT.B27 = 1;
  PFC.PDIORH.BIT.B26 = 1;
  PFC.PDIORH.BIT.B25 = 1;
  PFC.PDIORH.BIT.B24 = 1;
  PFC.PDIORH.BIT.B23 = 1;
  PFC.PDIORH.BIT.B22 = 1;
  PFC.PDIORH.BIT.B21 = 1;
  PFC.PDIORH.BIT.B20 = 1;
  PFC.PDIORH.BIT.B19 = 1;
  PFC.PDIORH.BIT.B18 = 1;
  PFC.PDIORH.BIT.B17 = 1;
  PFC.PDIORH.BIT.B16 = 1;
  PFC.PDIORL.WORD = 0;
  PFC.PDIORL.BIT.B15 = 1;
  PFC.PDIORL.BIT.B14 = 1;
  PFC.PDIORL.BIT.B13 = 1;
  PFC.PDIORL.BIT.B12 = 1;
  PFC.PDIORL.BIT.B11 = 1;
  PFC.PDIORL.BIT.B10 = 1;
  PFC.PDIORL.BIT.B9  = 1;
  PFC.PDIORL.BIT.B8  = 1;
  PFC.PDIORL.BIT.B7  = 1;
  PFC.PDIORL.BIT.B6  = 1;
  PFC.PDIORL.BIT.B5  = 1;
  PFC.PDIORL.BIT.B4  = 1;
  PFC.PDIORL.BIT.B3  = 1;
  PFC.PDIORL.BIT.B2  = 1;
  PFC.PDIORL.BIT.B1  = 1;
  PFC.PDIORL.BIT.B0  = 1;
  PFC.PDCRH1.WORD = 0;
  PFC.PDCRH1.BIT.MD31 = 3;
  PFC.PDCRH1.BIT.MD30 = 3;
  PFC.PDCRH1.BIT.MD29 = 3;
  PFC.PDCRH1.BIT.MD28 = 3;
  PFC.PDCRH1.BIT.MD27 = 3;
  PFC.PDCRH1.BIT.MD26 = 3;
  PFC.PDCRH1.BIT.MD25 = 3;
  PFC.PDCRH1.BIT.MD24 = 3;
  PFC.PDCRH2.WORD = 0;
  PFC.PDCRH2.BIT.MD23 = 3;
  PFC.PDCRH2.BIT.MD22 = 3;
  PFC.PDCRH2.BIT.MD21 = 3;
  PFC.PDCRH2.BIT.MD20 = 3;
  PFC.PDCRH2.BIT.MD19 = 3;
  PFC.PDCRH2.BIT.MD18 = 3;
  PFC.PDCRH2.BIT.MD17 = 3;
  PFC.PDCRH2.BIT.MD16 = 3;
  PFC.PDCRL.WORD = 0;
  PFC.PDCRL.BIT.MD15 = 1;
  PFC.PDCRL.BIT.MD14 = 1;
  PFC.PDCRL.BIT.MD13 = 1;
  PFC.PDCRL.BIT.MD12 = 1;
  PFC.PDCRL.BIT.MD11 = 1;
  PFC.PDCRL.BIT.MD10 = 1;
  PFC.PDCRL.BIT.MD9  = 1;
  PFC.PDCRL.BIT.MD8  = 1;
  PFC.PDCRL.BIT.MD7  = 1;
  PFC.PDCRL.BIT.MD6  = 1;
  PFC.PDCRL.BIT.MD5  = 1;
  PFC.PDCRL.BIT.MD4  = 1;
  PFC.PDCRL.BIT.MD3  = 1;
  PFC.PDCRL.BIT.MD2  = 1;
  PFC.PDCRL.BIT.MD1  = 1;
  PFC.PDCRL.BIT.MD0  = 1;
  PFC.PEIOR.WORD = 0;
  PFC.PEIOR.BIT.B15 = 1;
  PFC.PEIOR.BIT.B14 = 1;
  PFC.PEIOR.BIT.B13 = 1;
  PFC.PEIOR.BIT.B12 = 1;
  PFC.PEIOR.BIT.B11 = 1;
  PFC.PEIOR.BIT.B10 = 1;
  PFC.PEIOR.BIT.B9  = 1;
  PFC.PEIOR.BIT.B8  = 1;
  PFC.PEIOR.BIT.B7  = 1;
  PFC.PEIOR.BIT.B6  = 1;
  PFC.PEIOR.BIT.B5  = 1;
  PFC.PEIOR.BIT.B4  = 1;
  PFC.PEIOR.BIT.B3  = 1;
  PFC.PEIOR.BIT.B2  = 1;
  PFC.PEIOR.BIT.B1  = 1;
  PFC.PEIOR.BIT.B0  = 1;
  PFC.PECR1.WORD = 0;
  PFC.PECR1.BIT.MD15 = 3;
  PFC.PECR1.BIT.MD14 = 3;
  PFC.PECR1.BIT.MD13 = 3;
  PFC.PECR1.BIT.MD12 = 1;
  PFC.PECR1.BIT.MD11 = 1;
  PFC.PECR1.BIT.MD10 = 1;
  PFC.PECR1.BIT.MD9  = 1;
  PFC.PECR1.BIT.MD8  = 1;
  PFC.PECR2.WORD = 0;
  PFC.PECR2.BIT.MD7  = 1;
  PFC.PECR2.BIT.MD6  = 1;
  PFC.PECR2.BIT.MD5  = 1;
  PFC.PECR2.BIT.MD4  = 1;
  PFC.PECR2.BIT.MD3  = 3;
  PFC.PECR2.BIT.MD2  = 3;
  PFC.PECR2.BIT.MD1  = 3;
  PFC.PECR2.BIT.MD0  = 3;
  PFC.IFCR.WORD = 0;
  PFC.IFCR.BIT.IRQMD32 = 3;
  PFC.IFCR.BIT.IRQMD10 = 3;
}

void cmt_set(void)
{
  CMT.CMSTR.WORD = 0;
  CMT.CMSTR.BIT.STR1 = 1;
  CMT.CMSTR.BIT.STR0 = 1;
  CMT0.CMCSR.WORD = 0;
  CMT0.CMCSR.BIT.CMF  = 1;
  CMT0.CMCSR.BIT.CMIE = 1;
  CMT0.CMCSR.BIT.CKS  = 3;
  CMT0.CMCNT = 0;
  CMT0.CMCOR = 0;
  CMT1.CMCSR.WORD = 0;
  CMT1.CMCSR.BIT.CMF  = 1;
  CMT1.CMCSR.BIT.CMIE = 1;
  CMT1.CMCSR.BIT.CKS  = 3;
  CMT1.CMCNT = 0;
  CMT1.CMCOR = 0;
}

void ad_set(void)
{
  AD.DRA.WORD = 0;
  AD.DRA.BYTE = 0;
  AD.DRB.WORD = 0;
  AD.DRB.BYTE = 0;
  AD.DRC.WORD = 0;
  AD.DRC.BYTE = 0;
  AD.DRD.WORD = 0;
  AD.DRD.BYTE = 0;
  AD.DRE.WORD = 0;
  AD.DRE.BYTE = 0;
  AD.DRF.WORD = 0;
  AD.DRF.BYTE = 0;
  AD.DRG.WORD = 0;
  AD.DRG.BYTE = 0;
  AD.DRH.WORD = 0;
  AD.DRH.BYTE = 0;
  AD.CSR.BYTE = 0;
  AD.CSR.BIT.ADF  = 1;
  AD.CSR.BIT.ADIE = 1;
  AD.CSR.BIT.ADST = 1;
  AD.CSR.BIT.CKS  = 1;
  AD.CSR.BIT.GRP  = 1;
  AD.CSR.BIT.CH   = 7;
  AD.CR.BYTE = 0;
  AD.CR.BIT.PWR  = 1;
  AD.CR.BIT.TRGS = 3;
  AD.CR.BIT.SCAN = 1;
  AD.CR.BIT.DSMP = 1;
  AD.CR.BIT.BUFE = 3;
}

void ubc_set(void)
{
  UBC.UBAR = ubc_set;
  UBC.UBAMR = 0;
  UBC.UBBR.WORD = 0;
  UBC.UBBR.BIT.CP = 3;
  UBC.UBBR.BIT.ID = 3;
  UBC.UBBR.BIT.RW = 3;
  UBC.UBBR.BIT.SZ = 3;
}

void sbycr_set(void)
{
  SBYCR.BYTE = 0;
  SBYCR.BIT.SBY = 1;
  SBYCR.BIT.HIZ = 1;
}

void bsc_set(void)
{
  BSC.BCR1.WORD = 0;
  BSC.BCR1.BIT.MTURWE = 1;
  BSC.BCR1.BIT.IOE    = 1;
  BSC.BCR1.BIT.A3LG   = 1;
  BSC.BCR1.BIT.A2LG   = 1;
  BSC.BCR1.BIT.A1LG   = 1;
  BSC.BCR1.BIT.A0LG   = 1;
  BSC.BCR1.BIT.A3SZ   = 1;
  BSC.BCR1.BIT.A2SZ   = 1;
  BSC.BCR1.BIT.A1SZ   = 1;
  BSC.BCR1.BIT.A0SZ   = 1;
  BSC.BCR2.WORD = 0;
  BSC.BCR2.BIT.IW3 = 3;
  BSC.BCR2.BIT.IW2 = 3;
  BSC.BCR2.BIT.IW1 = 3;
  BSC.BCR2.BIT.IW0 = 3;
  BSC.BCR2.BIT.CW3 = 1;
  BSC.BCR2.BIT.CW2 = 1;
  BSC.BCR2.BIT.CW1 = 1;
  BSC.BCR2.BIT.CW0 = 1;
  BSC.BCR2.BIT.SW3 = 1;
  BSC.BCR2.BIT.SW2 = 1;
  BSC.BCR2.BIT.SW1 = 1;
  BSC.BCR2.BIT.SW0 = 1;
  BSC.WCR1.WORD = 0;
  BSC.WCR1.BIT.W3 = 15;
  BSC.WCR1.BIT.W2 = 15;
  BSC.WCR1.BIT.W1 = 15;
  BSC.WCR1.BIT.W0 = 15;
  BSC.WCR2.WORD = 0;
  BSC.WCR2.BIT.DDW = 3;
  BSC.WCR2.BIT.DSW = 15;
  BSC.DCR.WORD = 0;
  BSC.DCR.BIT.TPC  = 1;
  BSC.DCR.BIT.RCD  = 1;
  BSC.DCR.BIT.TRAS = 3;
  BSC.DCR.BIT.DWW  = 3;
  BSC.DCR.BIT.DWR  = 3;
  BSC.DCR.BIT.DIW  = 1;
  BSC.DCR.BIT.BE   = 1;
  BSC.DCR.BIT.SZ   = 3;
  BSC.DCR.BIT.AMX  = 3;
  BSC.RTCSR.WORD = 0;
  BSC.RTCSR.BIT.CMF  = 1;
  BSC.RTCSR.BIT.CMIE = 1;
  BSC.RTCSR.BIT.CKS  = 7;
  BSC.RTCSR.BIT.RFSH = 1;
  BSC.RTCSR.BIT.RMD  = 1;
  BSC.RTCNT = 0;
  BSC.RTCOR = 0;
}

void dmac_set(void)
{
  DMAC.DMAOR.WORD = 0;
  DMAC.DMAOR.BIT.PR   = 1;
  DMAC.DMAOR.BIT.AE   = 1;
  DMAC.DMAOR.BIT.NMIF = 1;
  DMAC.DMAOR.BIT.DME  = 1;

  DMAC0.SAR = &a[0];
  DMAC0.DAR = &b[0];
  DMAC0.DMATCR = 0;
  DMAC0.CHCR.LONG = 0;
  DMAC0.CHCR.WORD.H = 0;
  DMAC0.CHCR.WORD.L = 0;
  DMAC0.CHCR.BIT.RL = 1;
  DMAC0.CHCR.BIT.AM = 1;
  DMAC0.CHCR.BIT.AL = 1;
  DMAC0.CHCR.BIT.DM = 3;
  DMAC0.CHCR.BIT.SM = 3;
  DMAC0.CHCR.BIT.RS = 15;
  DMAC0.CHCR.BIT.DS = 1;
  DMAC0.CHCR.BIT.TM = 1;
  DMAC0.CHCR.BIT.TS = 3;
  DMAC0.CHCR.BIT.IE = 1;
  DMAC0.CHCR.BIT.TE = 1;
  DMAC0.CHCR.BIT.DE = 1;

  DMAC1.SAR = &c[0];
  DMAC1.DAR = &d[0];
  DMAC1.DMATCR = 0;
  DMAC1.CHCR.LONG = 0;
  DMAC1.CHCR.WORD.H = 0;
  DMAC1.CHCR.WORD.L = 0;
  DMAC1.CHCR.BIT.AM = 1;
  DMAC1.CHCR.BIT.AL = 1;
  DMAC1.CHCR.BIT.DM = 3;
  DMAC1.CHCR.BIT.SM = 3;
  DMAC1.CHCR.BIT.RS = 15;
  DMAC1.CHCR.BIT.DS = 1;
  DMAC1.CHCR.BIT.TM = 1;
  DMAC1.CHCR.BIT.TS = 3;
  DMAC1.CHCR.BIT.IE = 1;
  DMAC1.CHCR.BIT.TE = 1;
  DMAC1.CHCR.BIT.DE = 1;

  DMAC2.SAR = &e[0];
  DMAC2.DAR = &f[0];
  DMAC2.DMATCR = 0;
  DMAC2.CHCR.LONG = 0;
  DMAC2.CHCR.WORD.H = 0;
  DMAC2.CHCR.WORD.L = 0;
  DMAC2.CHCR.BIT.RO = 1;
  DMAC2.CHCR.BIT.DM = 3;
  DMAC2.CHCR.BIT.SM = 3;
  DMAC2.CHCR.BIT.RS = 15;
  DMAC2.CHCR.BIT.DS = 1;
  DMAC2.CHCR.BIT.TM = 1;
  DMAC2.CHCR.BIT.TS = 3;
  DMAC2.CHCR.BIT.IE = 1;
  DMAC2.CHCR.BIT.TE = 1;
  DMAC2.CHCR.BIT.DE = 1;

  DMAC3.SAR = &g[0];
  DMAC3.DAR = &h[0];
  DMAC3.DMATCR = 0;
  DMAC3.CHCR.LONG = 0;
  DMAC3.CHCR.WORD.H = 0;
  DMAC3.CHCR.WORD.L = 0;
  DMAC3.CHCR.BIT.DI = 1;
  DMAC3.CHCR.BIT.DM = 3;
  DMAC3.CHCR.BIT.SM = 3;
  DMAC3.CHCR.BIT.RS = 15;
  DMAC3.CHCR.BIT.DS = 1;
  DMAC3.CHCR.BIT.TM = 1;
  DMAC3.CHCR.BIT.TS = 3;
  DMAC3.CHCR.BIT.IE = 1;
  DMAC3.CHCR.BIT.TE = 1;
  DMAC3.CHCR.BIT.DE = 1;
}

void dtc_set(void)
{
  DTC.DTEA.BYTE = 0;
  DTC.DTEA.BIT.B7 = 1;  /* TGI4A of MTU4     */
  DTC.DTEA.BIT.B6 = 1;  /* TGI4B of MTU4     */
  DTC.DTEA.BIT.B5 = 1;  /* TGI4C of MTU4     */
  DTC.DTEA.BIT.B4 = 1;  /* TGI4D of MTU4     */
  DTC.DTEA.BIT.B3 = 1;  /* TGI4V of MTU4     */
  DTC.DTEA.BIT.B2 = 1;  /* TGI3A of MTU3     */
  DTC.DTEA.BIT.B1 = 1;  /* TGI3B of MTU3     */
  DTC.DTEA.BIT.B0 = 1;  /* TGI3C of MTU3     */
  DTC.DTEB.BYTE = 0;
  DTC.DTEB.BIT.B7 = 1;  /* TGI3D of MTU3     */
  DTC.DTEB.BIT.B6 = 1;  /* TGI2A of MTU2     */
  DTC.DTEB.BIT.B5 = 1;  /* TGI2B of MTU2     */
  DTC.DTEB.BIT.B4 = 1;  /* TGI1A of MTU1     */
  DTC.DTEB.BIT.B3 = 1;  /* TGI1B of MTU1     */
  DTC.DTEB.BIT.B2 = 1;  /* TGI0A of MTU0     */
  DTC.DTEB.BIT.B1 = 1;  /* TGI0B of MTU0     */
  DTC.DTEB.BIT.B0 = 1;  /* TGI0C of MTU0     */
  DTC.DTEC.BYTE = 0;
  DTC.DTEC.BIT.B7 = 1;  /* TGI0D of MTU0     */
  DTC.DTEC.BIT.B6 = 1;  /* ADI of A/D        */
  DTC.DTEC.BIT.B5 = 1;  /* IRQ0              */
  DTC.DTEC.BIT.B4 = 1;  /* IRQ1              */
  DTC.DTEC.BIT.B3 = 1;  /* IRQ2              */
  DTC.DTEC.BIT.B2 = 1;  /* IRQ3              */
  DTC.DTEC.BIT.B1 = 1;  /* IRQ4              */
  DTC.DTEC.BIT.B0 = 1;  /* IRQ5              */
  DTC.DTED.BYTE = 0;
  DTC.DTED.BIT.B7 = 1;  /* IRQ6              */
  DTC.DTED.BIT.B6 = 1;  /* IRQ7              */
  DTC.DTED.BIT.B5 = 1;  /* CMI0 of CMT0      */
  DTC.DTED.BIT.B4 = 1;  /* CMI1 of CMT1      */
  DTC.DTED.BIT.B3 = 1;  /* RXI0 of SCI0      */
  DTC.DTED.BIT.B2 = 1;  /* TXI0 of SCI0      */
  DTC.DTED.BIT.B1 = 1;  /* RXI1 of SCI1      */
  DTC.DTED.BIT.B0 = 1;  /* TXI1 of SCI1      */
  DTC.DTEE.BYTE = 0;
  DTC.DTEE.BIT.B7 = 1;  /* CMI of BSC        */
  DTC.DTCSR.WORD = 0;
  DTC.DTCSR.BIT.NMIF  = 1;
  DTC.DTCSR.BIT.AE    = 1;
  DTC.DTCSR.BIT.SWDTE = 1;
  DTC.DTCSR.BIT.DTVEC = 255;
  DTC.DTBR = 0;
}

void ccr_set(void)
{
  CCR.WORD = 0;
  CCR.BIT.CEDRAM = 1;
  CCR.BIT.CECS3  = 1;
  CCR.BIT.CECS2  = 1;
  CCR.BIT.CECS1  = 1;
  CCR.BIT.CECS0  = 1;
}

void main(void)
{
  sci_set();
  mtu_set();
  pwm_set();
  intc_set();
  pa_set();
  pb_set();
  pc_set();
  pd_set();
  pe_set();
  pf_set();
  pfc_set();
  cmt_set();
  ad_set();
  ubc_set();
  sbycr_set();
  bsc_set();
  dmac_set();
  dtc_set();
  ccr_set();
}
