EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 446

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
- 430 -
void UART1_config(u8 brt)
{
/*********** select Timer2 as baud rate generator *****************/
if(brt == 2)
{
AUXR |= 0x01; //S1 BRT Use Timer2;
SetTimer2Baudraye(Baudrate1);
}
/*********** select Timer1 as baud rate generator *****************/
else
{
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)(Baudrate1 / 256);
TL1 = (u8)(Baudrate1 % 256);
ET1 = 0; //diable interrupt
INT_CLKO &= ~0x02; //does not output clock
TR1 = 1;
}
/*************************************************/
SCON = (SCON & 0x3f) | 0x40; //UART1 mode: 0x00: Synchronous 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
ES = 1; //enable interrupt
REN = 1; //enable recieving
P_SW1 &= 0x3f;
// P_SW1 |= 0x80; //UART1switch to: 0x00: P3.0 P3.1,
// 0x40: P3.6 P3.7,
// 0x80: P1.6 P1.7,
// 0xC0: P4.3 P4.4
B_TX1_Busy = 0;
TX1_Cnt = 0;
RX1_Cnt = 0;
}
//========================================================================
// function: void UART2_config(u8 brt)
// description: UART2 initialization function
// parameters: brt: baud rate selected, 2: select Timer2 as baud rate generator, other values: not valid.
// return: none.
// version: VER1.0
// date: 2014-11-28
// remark:
//========================================================================
void UART2_config(u8 brt)
{
if(brt == 2)
{
SetTimer2Baudraye(Baudrate2);

Table of Contents

Related product manuals