#pragma sfr
#pragma di
#pragma ei
/*#pragma interrupt INTSR0 UART0_RX
#pragma interrupt INTST0 UART0_TX*/
typedef unsigned char UCHAR;
typedef unsigned int UINT;
UCHAR tflag;
UCHAR LED[5]={0x0D,0x0B,0x07,0x0E,0x0F};
UCHAR LEDP[5]={0x05,0x04,0x03,0x02,0x01};
void Clock_Init(void)
{
IMS = 0xC8;
IXS = 0x0C;
/* Set fxh */
OSCCTL = 0; /* X1, X2 as I/O port */
MSTOP = 1;
/* Set frh */
RSTOP = 0;
/* Set fprs */
MCM = 0; /* fxp = frh,fprs = frh */
/* Set fsub */
XTSTART = 0;
/* Set fcpu */
PCC = 0x00; /* fcpu = fxp */
/* Set frl */
LSRSTOP = 0;
}
void Uart_Init(void)
{
ASIM0 = 0xe5;
BRGC0 = 0xCD;
STMK0 = 1;
SRMK0 = 1;
STIF0 = 1;
SRIF0 = 1;
}
void Port_Init(void)
{ PM1 = 0X02;
/* P1 = 0x03;*/
P6 = 0xFF; /* P6.0~P6.3 output 1 */
PM6 = 0x00; /* P6.0~P6.3 as output mode */
}
void TM00_Start(void)
{
TMMK000 = 0x00; /* INTTM000 enabled */
TMC00 = 0x0C; /*Start Count operation*/
}
void main(void)
{
UINT i,flag;
DI( ); /*Disable interrupt*/
Clock_Init();
Port_Init();
Uart_Init();
EI( ); /*Enable interrupt*/
while(1)
{
if(SRIF0 == 1)
{
LEDP[1] = RXB0;
P6=0x00;
while(SRIF0);
SRIF0 = 0;
flag = 1;
}
if(tflag == 1)
{
tflag = 0;
TXS0 = LEDP[1];
P6=0x00;
while(STIF0);
STIF0 = 0;
flag = 0;
}
}
}
/*__interrupt void UART0_RX( void )
{
LEDP[4] = RXB0;
P6=0x00;
tflag = 1;
}
__interrupt void UART0_TX( void )
{
UCHAR i;
P6=0x0f;
TXS0 = 0x34;
}
*/