void InitialUART0_Timer1(UINT32 u32Baudrate) //T1M = 1, SMOD = 1
{
P06_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
P07_Quasi_Mode; //Setting UART pin as Quasi mode for transmit
SCON |= 0xd0 ; //UART0 Mode2,REN=1,TI=1
TMOD |= 0x20; //Timer1 Mode1
// set_SM2;
set_RB8;
set_TB8;
set_SMOD; //UART0 Double Rate Enable
set_T1M;
clr_BRCK; //Serial port 0 baud rate clock source = Timer1
//AUXR1 |=0X04;
#ifdef FOSC_160000
TH1 = 256 - (1000000/u32Baudrate+1); /*16 MHz */
#endif
#ifdef FOSC_166000
TH1 = 256 - (1037500/u32Baudrate); /*16.6 MHz */
#endif
clr_TI;
set_TR1;
set_TI; //For printf function must setting TI = 1
} |