|
- serial_init () {
- SCON = 0x50; /* mode 1: 8-bit UART, enable receiver */
- TMOD ?= 0x20; /* timer 1 mode 2: 8-Bit reload */
- PCON ?= 0x80; TH1 = 0xfA;//fa, //baud*2 /* reload value 19200 baud */
- TR2 = 1; /* timer 1 run */
- ES = 1; REN=1; EA=1; SM2=1; //SM2=1时收到的第9位为1才置位RI标志
- TMOD ?=0x01;
- TH0=31;
- TL0=0;
- TR0=1;
- }
复制代码
TH = 256 - (k*OscFreq)/(32*12*BaudRate)
k=1 if SMOD(PCON.7) = 0
k=2 if SMOD(PCON.7)= 1 |
|