//Other values: Use Timer1 as baud rate generator.
{
/*********** Use Timer2 as baud rate generator *****************/
if(brt == 2)
{
AUXR |= 0x01; //S1 BRT Use Timer2;
SetTimer2Baudraye(65536UL - (MAIN_Fosc / 4) / Baudrate1);
}
/*********** Use 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)((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;
}
void UART1_DMA_Interrupt(void) interrupt 13
{
if (DMA_UR1T_STA & 0x01) //send completed
{
DMA_UR1T_STA &= ~0x01;
DMATxFlag = 1;
}
if (DMA_UR1T_STA & 0x04) //data coverage
{
DMA_UR1T_STA &= ~0x04;
}
if (DMA_UR1R_STA & 0x01) //Receive complete
{
DMA_UR1R_STA &= ~0x01;
DMARxFlag = 1;
}
if (DMA_UR1R_STA & 0x02) //data is discarded
{
DMA_UR1R_STA &= ~0x02;
}