#include "7034.h"

char  a[10],b[10];
int   c[10],d[10];
short 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;
  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;
  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 ad_set(void)
{
  AD.DRA = 0;
  AD.DRB = 0;
  AD.DRC = 0;
  AD.DRD = 0;
  AD.CSR.BYTE = 0;
  AD.CSR.BIT.ADF  = 1;
  AD.CSR.BIT.ADIE = 1;
  AD.CSR.BIT.ADST = 1;
  AD.CSR.BIT.SCAN = 1;
  AD.CSR.BIT.CKS  = 1;
  AD.CSR.BIT.CH   = 7;
  AD.CR.BYTE = 0;
  AD.CR.BIT.TRGE = 1;
}

void itu_set(void)
{
  ITU.TSTR.BYTE = 0;
  ITU.TSTR.BIT.STR4 = 1;
  ITU.TSTR.BIT.STR3 = 1;
  ITU.TSTR.BIT.STR2 = 1;
  ITU.TSTR.BIT.STR1 = 1;
  ITU.TSTR.BIT.STR0 = 1;
  ITU.TSNC.BYTE = 0;
  ITU.TSNC.BIT.SYNC4 = 1;
  ITU.TSNC.BIT.SYNC3 = 1;
  ITU.TSNC.BIT.SYNC2 = 1;
  ITU.TSNC.BIT.SYNC1 = 1;
  ITU.TSNC.BIT.SYNC0 = 1;
  ITU.TMDR.BYTE = 0;
  ITU.TMDR.BIT.MDF  = 1;
  ITU.TMDR.BIT.FDIR = 1;
  ITU.TMDR.BIT.PWM4 = 1;
  ITU.TMDR.BIT.PWM3 = 1;
  ITU.TMDR.BIT.PWM2 = 1;
  ITU.TMDR.BIT.PWM1 = 1;
  ITU.TMDR.BIT.PWM0 = 1;
  ITU.TFCR.BYTE = 0;
  ITU.TFCR.BIT.CMD  = 3;
  ITU.TFCR.BIT.BFB4 = 1;
  ITU.TFCR.BIT.BFA4 = 1;
  ITU.TFCR.BIT.BFB3 = 1;
  ITU.TFCR.BIT.BFA3 = 1;
  ITU.TOCR.BYTE = 0;
  ITU.TOCR.BIT.OLS4 = 1;
  ITU.TOCR.BIT.OLS3 = 1;

  ITU0.TCR.BYTE = 0;
  ITU0.TCR.BIT.CCLR = 3;
  ITU0.TCR.BIT.CKEG = 3;
  ITU0.TCR.BIT.TPSC = 7;
  ITU0.TIOR.BYTE = 0;
  ITU0.TIOR.BIT.IOB = 7;
  ITU0.TIOR.BIT.IOA = 7;
  ITU0.TIER.BYTE = 0;
  ITU0.TIER.BIT.OVIE  = 1;
  ITU0.TIER.BIT.IMIEB = 1;
  ITU0.TIER.BIT.IMIEA = 1;
  ITU0.TSR.BYTE = 0;
  ITU0.TSR.BIT.OVF  = 1;
  ITU0.TSR.BIT.IMFB = 1;
  ITU0.TSR.BIT.IMFA = 1;
  ITU0.TCNT = 0;
  ITU0.GRA = 0;
  ITU0.GRB = 0;

  ITU1.TCR.BYTE = 0;
  ITU1.TCR.BIT.CCLR = 3;
  ITU1.TCR.BIT.CKEG = 3;
  ITU1.TCR.BIT.TPSC = 7;
  ITU1.TIOR.BYTE = 0;
  ITU1.TIOR.BIT.IOB = 7;
  ITU1.TIOR.BIT.IOA = 7;
  ITU1.TIER.BYTE = 0;
  ITU1.TIER.BIT.OVIE  = 1;
  ITU1.TIER.BIT.IMIEB = 1;
  ITU1.TIER.BIT.IMIEA = 1;
  ITU1.TSR.BYTE = 0;
  ITU1.TSR.BIT.OVF  = 1;
  ITU1.TSR.BIT.IMFB = 1;
  ITU1.TSR.BIT.IMFA = 1;
  ITU1.TCNT = 0;
  ITU1.GRA = 0;
  ITU1.GRB = 0;

  ITU2.TCR.BYTE = 0;
  ITU2.TCR.BIT.CCLR = 3;
  ITU2.TCR.BIT.CKEG = 3;
  ITU2.TCR.BIT.TPSC = 7;
  ITU2.TIOR.BYTE = 0;
  ITU2.TIOR.BIT.IOB = 7;
  ITU2.TIOR.BIT.IOA = 7;
  ITU2.TIER.BYTE = 0;
  ITU2.TIER.BIT.OVIE  = 1;
  ITU2.TIER.BIT.IMIEB = 1;
  ITU2.TIER.BIT.IMIEA = 1;
  ITU2.TSR.BYTE = 0;
  ITU2.TSR.BIT.OVF  = 1;
  ITU2.TSR.BIT.IMFB = 1;
  ITU2.TSR.BIT.IMFA = 1;
  ITU2.TCNT = 0;
  ITU2.GRA = 0;
  ITU2.GRB = 0;

  ITU3.TCR.BYTE = 0;
  ITU3.TCR.BIT.CCLR = 3;
  ITU3.TCR.BIT.CKEG = 3;
  ITU3.TCR.BIT.TPSC = 7;
  ITU3.TIOR.BYTE = 0;
  ITU3.TIOR.BIT.IOB = 7;
  ITU3.TIOR.BIT.IOA = 7;
  ITU3.TIER.BYTE = 0;
  ITU3.TIER.BIT.OVIE  = 1;
  ITU3.TIER.BIT.IMIEB = 1;
  ITU3.TIER.BIT.IMIEA = 1;
  ITU3.TSR.BYTE = 0;
  ITU3.TSR.BIT.OVF  = 1;
  ITU3.TSR.BIT.IMFB = 1;
  ITU3.TSR.BIT.IMFA = 1;
  ITU3.TCNT = 0;
  ITU3.GRA = 0;
  ITU3.GRB = 0;
  ITU3.BRA = 0;
  ITU3.BRB = 0;

  ITU4.TCR.BYTE = 0;
  ITU4.TCR.BIT.CCLR = 3;
  ITU4.TCR.BIT.CKEG = 3;
  ITU4.TCR.BIT.TPSC = 7;
  ITU4.TIOR.BYTE = 0;
  ITU4.TIOR.BIT.IOB = 7;
  ITU4.TIOR.BIT.IOA = 7;
  ITU4.TIER.BYTE = 0;
  ITU4.TIER.BIT.OVIE  = 1;
  ITU4.TIER.BIT.IMIEB = 1;
  ITU4.TIER.BIT.IMIEA = 1;
  ITU4.TSR.BYTE = 0;
  ITU4.TSR.BIT.OVF  = 1;
  ITU4.TSR.BIT.IMFB = 1;
  ITU4.TSR.BIT.IMFA = 1;
  ITU4.TCNT = 0;
  ITU4.GRA = 0;
  ITU4.GRB = 0;
  ITU4.BRA = 0;
  ITU4.BRB = 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.TCR = 0;
  DMAC0.CHCR.WORD = 0;
  DMAC0.CHCR.BIT.DM = 3;
  DMAC0.CHCR.BIT.SM = 3;
  DMAC0.CHCR.BIT.RS = 15;
  DMAC0.CHCR.BIT.AM = 1;
  DMAC0.CHCR.BIT.AL = 1;
  DMAC0.CHCR.BIT.DS = 1;
  DMAC0.CHCR.BIT.TM = 1;
  DMAC0.CHCR.BIT.TS = 1;
  DMAC0.CHCR.BIT.IE = 1;
  DMAC0.CHCR.BIT.TE = 1;
  DMAC0.CHCR.BIT.DE = 1;

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

  DMAC2.SAR = &e[0];
  DMAC2.DAR = &f[0];
  DMAC2.TCR = 0;
  DMAC2.CHCR.WORD = 0;
  DMAC2.CHCR.BIT.DM = 3;
  DMAC2.CHCR.BIT.SM = 3;
  DMAC2.CHCR.BIT.RS = 15;
  DMAC2.CHCR.BIT.AM = 1;
  DMAC2.CHCR.BIT.AL = 1;
  DMAC2.CHCR.BIT.DS = 1;
  DMAC2.CHCR.BIT.TM = 1;
  DMAC2.CHCR.BIT.TS = 1;
  DMAC2.CHCR.BIT.IE = 1;
  DMAC2.CHCR.BIT.TE = 1;
  DMAC2.CHCR.BIT.DE = 1;

  DMAC3.SAR = &g[0];
  DMAC3.DAR = &h[0];
  DMAC3.TCR = 0;
  DMAC3.CHCR.WORD = 0;
  DMAC3.CHCR.BIT.DM = 3;
  DMAC3.CHCR.BIT.SM = 3;
  DMAC3.CHCR.BIT.RS = 15;
  DMAC3.CHCR.BIT.AM = 1;
  DMAC3.CHCR.BIT.AL = 1;
  DMAC3.CHCR.BIT.DS = 1;
  DMAC3.CHCR.BIT.TM = 1;
  DMAC3.CHCR.BIT.TS = 1;
  DMAC3.CHCR.BIT.IE = 1;
  DMAC3.CHCR.BIT.TE = 1;
  DMAC3.CHCR.BIT.DE = 1;
}

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,1 Interrupt Level */
  INTC.IPRC.BIT.UL = 15;  /* Set DMAC2,3 Interrupt Level */
  INTC.IPRC.BIT.LU = 15;  /* Set ITU0 Interrupt Level */
  INTC.IPRC.BIT.LL = 15;  /* Set ITU1 Interrupt Level */
  INTC.IPRD.WORD = 0;
  INTC.IPRD.BIT.UU = 15;  /* Set ITU2 Interrupt Level */
  INTC.IPRD.BIT.UL = 15;  /* Set ITU3 Interrupt Level */
  INTC.IPRD.BIT.LU = 15;  /* Set ITU4 Interrupt Level */
  INTC.IPRD.BIT.LL = 15;  /* Set SCI0 Interrupt Level */
  INTC.IPRE.WORD = 0;
  INTC.IPRE.BIT.UU = 15;  /* Set SCI1    Interrupt Level */
  INTC.IPRE.BIT.UL = 15;  /* Set PRT,A/D Interrupt Level */
  INTC.IPRE.BIT.LU = 15;  /* Set WDT,REF 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;
}

void ubc_set(void)
{
  UBC.BAR = ubc_set;
  UBC.BAMR = 0;
  UBC.BBR.WORD = 0;
  UBC.BBR.BIT.CD = 3;
  UBC.BBR.BIT.ID = 3;
  UBC.BBR.BIT.RW = 3;
  UBC.BBR.BIT.SZ = 3;
}

void bsc_set(void)
{
  BSC.BCR.WORD = 0;
  BSC.BCR.BIT.DRAME  = 1;
  BSC.BCR.BIT.IOE    = 1;
  BSC.BCR.BIT.WARP   = 1;
  BSC.BCR.BIT.RDDTY  = 1;
  BSC.BCR.BIT.BAS    = 1;
  BSC.WCR1.WORD = 0;
  BSC.WCR1.BIT.RW7 = 1;
  BSC.WCR1.BIT.RW6 = 1;
  BSC.WCR1.BIT.RW5 = 1;
  BSC.WCR1.BIT.RW4 = 1;
  BSC.WCR1.BIT.RW3 = 1;
  BSC.WCR1.BIT.RW2 = 1;
  BSC.WCR1.BIT.RW1 = 1;
  BSC.WCR1.BIT.RW0 = 1;
  BSC.WCR1.BIT.WW1 = 1;
  BSC.WCR2.WORD = 0;
  BSC.WCR2.BIT.DRW7 = 1;
  BSC.WCR2.BIT.DRW6 = 1;
  BSC.WCR2.BIT.DRW5 = 1;
  BSC.WCR2.BIT.DRW4 = 1;
  BSC.WCR2.BIT.DRW3 = 1;
  BSC.WCR2.BIT.DRW2 = 1;
  BSC.WCR2.BIT.DRW1 = 1;
  BSC.WCR2.BIT.DRW0 = 1;
  BSC.WCR2.BIT.DWW7 = 1;
  BSC.WCR2.BIT.DWW6 = 1;
  BSC.WCR2.BIT.DWW5 = 1;
  BSC.WCR2.BIT.DWW4 = 1;
  BSC.WCR2.BIT.DWW3 = 1;
  BSC.WCR2.BIT.DWW2 = 1;
  BSC.WCR2.BIT.DWW1 = 1;
  BSC.WCR2.BIT.DWW0 = 1;
  BSC.WCR3.WORD = 0;
  BSC.WCR3.BIT.WPU   = 1;
  BSC.WCR3.BIT.A02LW = 3;
  BSC.WCR3.BIT.A6LW  = 3;
  BSC.DCR.WORD = 0;
  BSC.DCR.BIT.CW2  = 1;
  BSC.DCR.BIT.RASD = 1;
/* #undef TPC            */
/* BSC.DCR.BIT.TPC  = 1; */
  BSC.DCR.BIT.BE   = 1;
  BSC.DCR.BIT.CDTY = 1;
  BSC.DCR.BIT.MXE  = 1;
  BSC.DCR.BIT.MXC  = 3;
  BSC.PCR.WORD = 0;
  BSC.PCR.BIT.PEF  = 1;
  BSC.PCR.BIT.PFRC = 1;
  BSC.PCR.BIT.PEO  = 1;
  BSC.PCR.BIT.PCHK = 3;
  BSC.RCR.WORD = 0;
  BSC.RCR.BIT.RFSHE = 1;
  BSC.RCR.BIT.RMODE = 1;
  BSC.RCR.BIT.RLW   = 3;
  BSC.RTCSR.WORD = 0;
  BSC.RTCSR.BIT.CMF  = 1;
  BSC.RTCSR.BIT.CMIE = 1;
  BSC.RTCSR.BIT.CKS  = 7;
  BSC.RTCNT = 0;
  BSC.RTCOR = 0;
}

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

void pa_set(void)
{
  PA.DR.WORD = 0;
  PA.DR.BYTE.H = 0;
  PA.DR.BYTE.L = 0;
  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.B15 = 1;
  PB.DR.BIT.B14 = 1;
  PB.DR.BIT.B13 = 1;
  PB.DR.BIT.B12 = 1;
  PB.DR.BIT.B11 = 1;
  PB.DR.BIT.B10 = 1;
  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.BYTE = 0;
  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 pfc_set(void)
{
  PFC.PAIOR.WORD = 0;
  PFC.PAIOR.BIT.B15 = 1;
  PFC.PAIOR.BIT.B14 = 1;
  PFC.PAIOR.BIT.B13 = 1;
  PFC.PAIOR.BIT.B12 = 1;
  PFC.PAIOR.BIT.B11 = 1;
  PFC.PAIOR.BIT.B10 = 1;
  PFC.PAIOR.BIT.B9  = 1;
  PFC.PAIOR.BIT.B8  = 1;
  PFC.PAIOR.BIT.B7  = 1;
  PFC.PAIOR.BIT.B6  = 1;
  PFC.PAIOR.BIT.B5  = 1;
  PFC.PAIOR.BIT.B4  = 1;
  PFC.PAIOR.BIT.B3  = 1;
  PFC.PAIOR.BIT.B2  = 1;
  PFC.PAIOR.BIT.B1  = 1;
  PFC.PAIOR.BIT.B0  = 1;
  PFC.PBIOR.WORD = 0;
  PFC.PBIOR.BIT.B15 = 1;
  PFC.PBIOR.BIT.B14 = 1;
  PFC.PBIOR.BIT.B13 = 1;
  PFC.PBIOR.BIT.B12 = 1;
  PFC.PBIOR.BIT.B11 = 1;
  PFC.PBIOR.BIT.B10 = 1;
  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.PACR1.WORD = 0;
  PFC.PACR1.BIT.MD15 = 3;
  PFC.PACR1.BIT.MD14 = 3;
  PFC.PACR1.BIT.MD13 = 3;
  PFC.PACR1.BIT.MD12 = 3;
  PFC.PACR1.BIT.MD11 = 3;
  PFC.PACR1.BIT.MD10 = 3;
  PFC.PACR1.BIT.MD9  = 3;
  PFC.PACR1.BIT.MD8  = 1;
  PFC.PACR2.WORD = 0;
  PFC.PACR2.BIT.MD7 = 1;
  PFC.PACR2.BIT.MD6 = 1;
  PFC.PACR2.BIT.MD5 = 1;
  PFC.PACR2.BIT.MD4 = 1;
  PFC.PACR2.BIT.MD3 = 3;
  PFC.PACR2.BIT.MD2 = 3;
  PFC.PACR2.BIT.MD1 = 3;
  PFC.PACR2.BIT.MD0 = 3;
  PFC.PBCR1.WORD = 0;
  PFC.PBCR1.BIT.MD15 = 3;
  PFC.PBCR1.BIT.MD14 = 3;
  PFC.PBCR1.BIT.MD13 = 3;
  PFC.PBCR1.BIT.MD12 = 3;
  PFC.PBCR1.BIT.MD11 = 3;
  PFC.PBCR1.BIT.MD10 = 3;
  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 = 3;
  PFC.PBCR2.BIT.MD0 = 3;
  PFC.CASCR.WORD = 0;
  PFC.CASCR.BIT.CASHMD = 3;
  PFC.CASCR.BIT.CASLMD = 3;
}

void tpc_set(void)
{
  TPC.TPMR.BYTE = 0;
  TPC.TPMR.BIT.G3NOV = 1;
  TPC.TPMR.BIT.G2NOV = 1;
  TPC.TPMR.BIT.G1NOV = 1;
  TPC.TPMR.BIT.G0NOV = 1;
  TPC.TPCR.BYTE = 0;
  TPC.TPCR.BIT.G3CMS = 3;
  TPC.TPCR.BIT.G2CMS = 3;
  TPC.TPCR.BIT.G1CMS = 3;
  TPC.TPCR.BIT.G0CMS = 3;
  TPC.NDERB.BYTE = 0;
  TPC.NDERB.BIT.B15 = 1;
  TPC.NDERB.BIT.B14 = 1;
  TPC.NDERB.BIT.B13 = 1;
  TPC.NDERB.BIT.B12 = 1;
  TPC.NDERB.BIT.B11 = 1;
  TPC.NDERB.BIT.B10 = 1;
  TPC.NDERB.BIT.B9  = 1;
  TPC.NDERB.BIT.B8  = 1;
  TPC.NDERA.BYTE = 0;
  TPC.NDERA.BIT.B7 = 1;
  TPC.NDERA.BIT.B6 = 1;
  TPC.NDERA.BIT.B5 = 1;
  TPC.NDERA.BIT.B4 = 1;
  TPC.NDERA.BIT.B3 = 1;
  TPC.NDERA.BIT.B2 = 1;
  TPC.NDERA.BIT.B1 = 1;
  TPC.NDERA.BIT.B0 = 1;
  TPC.NDRB1.BYTE = 0;     /* Address is H'F4 */
  TPC.NDRB1.BIT.B15 = 1;
  TPC.NDRB1.BIT.B14 = 1;
  TPC.NDRB1.BIT.B13 = 1;
  TPC.NDRB1.BIT.B12 = 1;
  TPC.NDRB1.BIT.B11 = 1;
  TPC.NDRB1.BIT.B10 = 1;
  TPC.NDRB1.BIT.B9  = 1;
  TPC.NDRB1.BIT.B8  = 1;
  TPC.NDRB2.BYTE = 0;     /* Address is H'F6 */
  TPC.NDRB2.BIT.B11 = 1;
  TPC.NDRB2.BIT.B10 = 1;
  TPC.NDRB2.BIT.B9  = 1;
  TPC.NDRB2.BIT.B8  = 1;
  TPC.NDRA1.BYTE = 0;     /* Address is H'F5 */
  TPC.NDRA1.BIT.B7 = 1;
  TPC.NDRA1.BIT.B6 = 1;
  TPC.NDRA1.BIT.B5 = 1;
  TPC.NDRA1.BIT.B4 = 1;
  TPC.NDRA1.BIT.B3 = 1;
  TPC.NDRA1.BIT.B2 = 1;
  TPC.NDRA1.BIT.B1 = 1;
  TPC.NDRA1.BIT.B0 = 1;
  TPC.NDRA2.BYTE = 0;     /* Address is H'F7 */
  TPC.NDRA2.BIT.B3 = 1;
  TPC.NDRA2.BIT.B2 = 1;
  TPC.NDRA2.BIT.B1 = 1;
  TPC.NDRA2.BIT.B0 = 1;
}

void main(void)
{
  sci_set();
  ad_set();
  itu_set();
  dmac_set();
  intc_set();
  ubc_set();
  bsc_set();
  sbycr_set();
  pa_set();
  pb_set();
  pc_set();
  pfc_set();
  tpc_set();
}
