EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 678

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
- 662 -
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)((65536UL - (MAIN_Fosc / 4) / Baudrate1) / 256);
TL1 = (u8)((65536UL - (MAIN_Fosc / 4) / Baudrate1) % 256);
ET1 = 0; //Disable interrupts
INTCLKO &= ~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 interrupt
ES = 1; //enable interrupt
REN = 1; //enable to receive
P_SW1 &= 0x3f;
P_SW1 |= 0x00; //UART1 switch to:
//0x00: P3.0 P3.1,
//0x40: P3.6 P3.7,
//0x80: P1.6 P1.7,
//0xC0: P4.3 P4.4
RX1_TimeOut = 0;
}
void UART1_int (void) interrupt 4
{
if(RI)
{
RI = 0;
Rx_cnt++;
if(Rx_cnt >= DMA_AMT_LEN) Rx_cnt = 0;
RX1_TimeOut = 5; //If no new data is received within 5ms, it is determined that a string
of data has been received.
}
if(TI)
{
TI = 0;
BusyFlag = 0;
}
}
void timer0 (void) interrupt 1
{
B_1ms = 1; //1ms flag
}
void UART1_DMA_Interrupt(void) interrupt 13
{
if (DMA_UR1T_STA & 0x01) //send completed
{

Table of Contents

Related product manuals