EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 485

Default Icon
901 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
STC8A8K64D4 Series Manual
- 469 -
// Remark:
//========================================================================
void UART1_config(void)
{
TR1 = 0;
AUXR &= ~0x01; //S1 BRT Use Timer1;
AUXR |= (1<<6); //Timer1 set as 1T mode
TMOD &= ~(1<<6); //Timer1 set As Timer
TMOD &= ~0x30; //Timer1_16bitAutoReload;
TH1 = (u8)((65536L-(MAIN_Fosc / 4) / Baudrate1) >> 8);
TL1 = (u8)(65536L-(MAIN_Fosc / 4) / Baudrate1);
ET1 = 0; // Diable Timer1 interrupt
INT_CLKO &= ~0x02; // Timer1 does not output high-speed clock
TR1 = 1; // Start Timer1
S1_USE_P30P31(); P3n_standard(0x03); //Switch to P3.0 P3.1
//S1_USE_P36P37(); P3n_standard(0xc0); //Switch to P3.6 P3.7
//S1_USE_P16P17(); P1n_standard(0xc0); //Switch to P1.6 P1.7
SCON = (SCON & 0x3f) | 0x40; //UART1 mode, 0x00: synchronized shift output,
// 0x40: 8-bit data, variable baud rate,
// 0x80: 9-bit data, fixed baud rate,
// 0xc0: 9-bit data, variable baud rate
// PS = 1; //high priority interrupt
ES = 1; //enable interrupt
REN = 1; //enable receiving
B_TX1_Busy = 0;
RX1_Cnt = 0;
}
//========================================================================
// Function: void UART1_int (void) interrupt UART1_VECTOR
// Description: UART1 interrupt function
// Parameters:nine.
// Return: none.
// Version: VER1.0
// Date: 2014-11-28
// Remark:
//========================================================================
void UART1_int (void) interrupt 4
{
if(RI)
{
RI = 0;
if(RX1_Cnt >= UART1_BUF_LENGTH)
RX1_Cnt = 0; //avoid overflow
RX1_Buffer[RX1_Cnt++] = SBUF;
RX1_TimeOut = TimeOutSet1;
}
if(TI)
{
TI = 0;
B_TX1_Busy = 0;
}
}

Table of Contents

Related product manuals