定时器3串口0模式3代码实现:
P06_Quasi_Mode;
P07_Quasi_Mode;
SCON = 0xD0; //UART0 Mode3,REN=1,TI=1
set_SMOD; //UART0 Double Rate Enable
T3CON = 0xF8; //T3PS2=0,T3PS1=0,T3PS0=0(Prescale=1)
set_BRCK; //UART0 baud rate clock source = Timer3
#ifdef FOSC_240000
RH3 = HIBYTE(65536 - (1500000/u32Baudrate));
RL3 = LOBYTE(65536 - (1500000/u32Baudrate));
#endif
set_TR3; //Trigger Timer3
set_RB8; //This bit is for setting the stop bit 2 high/low status,
TI = 0;
set_ES; //enable UART interrupt
set_EA; //enable global interrupt
定时器3串口1模式3代码实现:
P02_Quasi_Mode;
P16_Quasi_Mode;
SCON_1 = 0xD2; //UART1 Mode3,REN=1,TI=1
set_SMOD_1; //UART1 Double Rate Enable
T3CON = 0xF8; //T3PS2=0,T3PS1=0,T3PS0=0(Prescale=1)
set_BRCK; //UART1 baud rate clock source = Timer3
#ifdef FOSC_160000
RH3 = HIBYTE(65536 - (1000000/u32Baudrate));
RL3 = LOBYTE(65536 - (1000000/u32Baudrate));
#endif
#ifdef FOSC_240000
RH3 = HIBYTE(65536 - (1500000/u32Baudrate));
RL3 = LOBYTE(65536 - (1500000/u32Baudrate));
#endif
set_TR3; //Trigger Timer3
set_RB8_1; //This bit is for setting the stop bit 2 high/low status,
TI_1 = 1;
set_ES_1; //enable UART interrupt
set_EA; //enable global interrupt
|