本帖最后由 Anthonybrave 于 2015-12-23 13:03 编辑
是否能够用同一个定时器进行设置波特率 ?
这是进行初始化的内容 但是 用上位机给串口1发送数据时,进不了中断
void Scon_Ini(void) // 串口0串口1 用定时器1
{
// unsigned short ii;
// UART0 Configuration
SFRPAGE = 0x00;
SSTA0 = 0x00; // UART0 Status and Clock Selection Register
SCON0 = 0x50; // Serial Port Control Register
ES0 = 1;
SFRPAGE = 0x01;
//uart1
SCON1 = 0x50;
EIE2 |= 0x40; // enable UART1 interrupts
SFRPAGE = 0x00;
TMOD |= 0x20; // TMOD: timer 1, mode 2, 8-bit reload
TH1 = -(SYSTEM_CLK/BAUDRATE/32);
//TH1 = 0xfd; // TH1: reload value for 19200 baud @ 22.1184MHz
TL1 = TH1; //0xfa=9600;
TR1 = 1; // TR1: timer 1 run
CKCON |= 0x10; // Timer1 uses SYSCLK as time base
} |