STC8A8K64D4 Series Manual
{
/*********** Use Timer2 as baud rate generator *****************/
if(brt == 2)
{
AUXR |= 0x01;
SetTimer2Baudraye(65536UL - (MAIN_Fosc / 4) / Baudrate1);
}
/*********** Use Timer1 as baud rate generator *****************/
else
{
TR1 = 0;
AUXR &= ~0x01;
AUXR |= (1<<6);
TMOD &= ~(1<<6);
TMOD &= ~0x30;
TH1 = (u8)((65536UL - (MAIN_Fosc / 4) / Baudrate1) / 256);
TL1 = (u8)((65536UL - (MAIN_Fosc / 4) / Baudrate1) % 256);
ET1 = 0;
INTCLKO &= ~0x02;
TR1 = 1;
}
/*************************************************/
SCON = (SCON & 0x3f) | 0x40;
//
PS = 1;
//
ES = 1;
REN = 1;
P_SW1 &= 0x3f;
P_SW1 |= 0x00;
}
void UART1_DMA_Interrupt(void) interrupt 13
{
if (DMA_UR1T_STA & 0x01)
{
DMA_UR1T_STA &= ~0x01;
DMATxFlag = 1;
}
if (DMA_UR1T_STA & 0x04)
{
DMA_UR1T_STA &= ~0x04;
}
if (DMA_UR1R_STA & 0x01)
{
DMA_UR1R_STA &= ~0x01;
DMARxFlag = 1;
}
if (DMA_UR1R_STA & 0x02)
{
DMA_UR1R_STA &= ~0x02;
}
//Other values: Use Timer1 as baud rate generator.
//S1 BRT Use Timer2;
//S1 BRT Use Timer1;
//Timer1 set as 1T mode
//Timer1 set As Timer
//Timer1_16bitAutoReload;
//Disable interrupts
//Does not output clock
//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
//high priority interrupt
//enable interrupt
//enable to receive
//send completed
//data coverage
//Receive complete
//data is discarded
- 668 -
Need help?
Do you have a question about the micro STC8A8K64D4 Series and is the answer not in the manual?