void MCU_init(void)
{
/* ### MC9S08AW60_64 "Cpu" init code ... */
/* PE initialization code after reset */
/* Common initialization of the write once registers */
/* SOPT: COPE=0,COPT=1,STOPE=0 */
SOPT = 0x53;
/* SPMSC1: LVDF=0,LVDACK=0,LVDIE=0,LVDRE=1,LVDSE=1,LVDE=1,BGBE=0 */
SPMSC1 = 0x1C;
/* SPMSC2: LVWF=0,LVWACK=0,LVDV=0,LVWV=0,PPDF=0,PPDACK=0,PPDC=0 */
SPMSC2 = 0x00;
/* SMCLK: MPE=0,MCSEL=0 */
SMCLK &= (unsigned char)~0x17;
/* System clock initialization */
/* ICGC1: HGO=0,RANGE=1,REFS=0,CLKS1=0,CLKS0=0,OSCSTEN=1,LOCD=0 */
ICGC1 = 0x44;
/* ICGFLT: FILT11=0,FILT10=0,FILT9=0,FILT8=0,FILT7=1,FILT6=1,FILT5=0,FILT4=0,FILT3=0,FILT2=0,FILT1=0,FILT0=0 */
ICGFLT = 0xC0; /* Initialization of the filter value */
/* ICGC2: LOLRE=0,MFD2=0,MFD1=0,MFD0=0,LOCRE=0,RFD2=0,RFD1=0,RFD0=0 */
ICGC2 = 0x00;
ICGTRM = *(unsigned char*far)0xFFBE; /* Initialize ICGTRM register from a non volatile memory */
/* Common initialization of the CPU registers */
/* PTASE: PTASE7=1,PTASE6=1,PTASE5=1,PTASE4=1,PTASE3=1,PTASE2=1,PTASE1=1,PTASE0=1 */
PTASE = 0xFF;
/* PTBSE: PTBSE7=1,PTBSE6=1,PTBSE5=1,PTBSE4=1,PTBSE3=1,PTBSE2=1,PTBSE1=1,PTBSE0=1 */
PTBSE = 0xFF;
/* PTCSE: PTCSE6=1,PTCSE5=1,PTCSE4=1,PTCSE3=1,PTCSE2=1,PTCSE1=1,PTCSE0=1 */
PTCSE |= (unsigned char)0x7F;
/* PTDSE: PTDSE7=1,PTDSE6=1,PTDSE5=1,PTDSE4=1,PTDSE3=1,PTDSE2=1,PTDSE1=1,PTDSE0=1 */
PTDSE = 0xFF;
/* PTESE: PTESE7=1,PTESE6=1,PTESE5=1,PTESE4=1,PTESE3=1,PTESE2=1,PTESE1=1,PTESE0=1 */
PTESE = 0xFF;
/* PTFSE: PTFSE7=1,PTFSE6=1,PTFSE5=1,PTFSE4=1,PTFSE3=1,PTFSE2=1,PTFSE1=1,PTFSE0=1 */
PTFSE = 0xFF;
/* PTGSE: PTGSE6=1,PTGSE5=1,PTGSE4=1,PTGSE3=1,PTGSE2=1,PTGSE1=1,PTGSE0=1 */
PTGSE |= (unsigned char)0x7F;
/* PTADS: PTADS7=0,PTADS6=0,PTADS5=0,PTADS4=0,PTADS3=0,PTADS2=0,PTADS1=0,PTADS0=0 */
PTADS = 0x00;
/* PTBDS: PTBDS7=0,PTBDS6=0,PTBDS5=0,PTBDS4=0,PTBDS3=0,PTBDS2=0,PTBDS1=0,PTBDS0=0 */
PTBDS = 0x00;
/* PTCDS: PTCDS6=0,PTCDS5=0,PTCDS4=0,PTCDS3=0,PTCDS2=0,PTCDS1=0,PTCDS0=0 */
PTCDS = 0x00;
/* PTDDS: PTDDS7=0,PTDDS6=0,PTDDS5=0,PTDDS4=0,PTDDS3=0,PTDDS2=0,PTDDS1=0,PTDDS0=0 */
PTDDS = 0x00;
/* PTEDS: PTEDS7=0,PTEDS6=0,PTEDS5=0,PTEDS4=0,PTEDS3=0,PTEDS2=0,PTEDS1=0,PTEDS0=0 */
PTEDS = 0x00;
/* PTFDS: PTFDS7=0,PTFDS6=0,PTFDS5=0,PTFDS4=0,PTFDS3=0,PTFDS2=0,PTFDS1=0,PTFDS0=0 */
PTFDS = 0x00;
/* PTGDS: PTGDS6=0,PTGDS5=0,PTGDS4=0,PTGDS3=0,PTGDS2=0,PTGDS1=0,PTGDS0=0 */
PTGDS = 0x00;
/* ### Init_SCI init code */
/* SCI1C2: TIE=0,TCIE=0,RIE=0,ILIE=0,TE=0,RE=0,RWU=0,SBK=0 */
SCI1C2 = 0x00; /* Disable the SCI1 module */
(void)(SCI1S1 == 0); /* Dummy read of the SCI1S1 registr to clear flags */
(void)(SCI1D == 0); /* Dummy read of the SCI1D registr to clear flags */
/* SCI1BD: SBR12=0,SBR11=0,SBR10=0,SBR9=0,SBR8=0,SBR7=0,SBR6=0,SBR5=0,SBR4=1,SBR3=1,SBR2=0,SBR1=1,SBR0=0 */
SCI1BD = 0x1A;
/* SCI1C1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */
SCI1C1 = 0x00;
/* SCI1C2: TIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */
SCI1C2 = 0x2C;
/* SCI1C3: R8=0,T8=0,TXDIR=0,TXINV=0,ORIE=0,NEIE=0,FEIE=0,PEIE=0 */
SCI1C3 = 0x00;
/* SCI1S2: BRK13=0,RAF=0 */
SCI1S2 = 0x00;
/* ### Init_SCI init code */
/* SCI2C2: TIE=0,TCIE=0,RIE=0,ILIE=0,TE=0,RE=0,RWU=0,SBK=0 */
SCI2C2 = 0x00; /* Disable the SCI2 module */
(void)(SCI2S1 == 0); /* Dummy read of the SCI2S1 registr to clear flags */
(void)(SCI2D == 0); /* Dummy read of the SCI2D registr to clear flags */
/* SCI2BD: SBR12=0,SBR11=0,SBR10=0,SBR9=0,SBR8=0,SBR7=0,SBR6=0,SBR5=0,SBR4=1,SBR3=1,SBR2=0,SBR1=1,SBR0=0 */
SCI2BD = 0x1A;
/* SCI2C1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */
SCI2C1 = 0x80;
/* SCI2C2: TIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */
SCI2C2 = 0x2C;
/* SCI2C3: R8=0,T8=0,TXDIR=0,TXINV=0,ORIE=0,NEIE=0,FEIE=0,PEIE=0 */
SCI2C3 = 0x00;
/* SCI2S2: BRK13=0,RAF=0 */
SCI2S2 = 0x00;
/* ### */
asm CLI; /* Enable interrupts */
} /*MCU_init*/
void MCU_init(void); /* Device initialization function declaration */
void main(void) {
unsigned char Temp;
MCU_init(); /* call Device Initialization */
/* include your code here */
//////////
EN485A = 1;
while (!SCI1S1_TDRE);
Temp = SCI1S1;
SCI1S1_TDRE=1;
SCI1D = 0x55;
EN485A = 0;
////
EN485B = 1;
while (!SCI2S1_TDRE);
Temp = SCI2S1;
SCI2S1_TDRE=1;
SCI2D = 0x55;
EN485B = 0;
///////
// task();
for(;;) {
/* __RESET_WATCHDOG(); by default, COP is disabled with device init. When enabling, also reset the watchdog. */
} /* loop forever */
/* please make sure that you never leave main */
} |