这次要做个调试板,接手别人的程序。他使用定时器1的溢出作为串口的波特率。在新华龙的例程里没有写
time1的中断处理函数。
但我在使用中发现。要是不写time1的中断处理函数就没法进 UART0的中断也就是没法
通信。
程序如下:
void UART0_Init(void)
{
unsigned char temp = SFRPAGE; // Save current SFR page
SFRPAGE = UART0_PAGE;
SCON0 = 0x50; // 8-Bit UART,variable baud rate.
// Receive Enable.
SSTA0 = 0x00; // Timer1 Overflow generates UART0 TX and
// RX baud rate.
SFRPAGE = TIMER01_PAGE;
TMOD = 0x20; // Timer1 enabled,Timer is in Auto-Reload Mode.
CKCON = 0x00; // Timer1 clock = SYSCLK/12. 22118400/12/19200=96
TH1 = 0xA0; // Baud rate = 19200. TH1=256-96=160
TL1 = 0xA0; //TL0 must be initialized to desired value before
//enable the timer for the first count
TCON = 0x40; // Timer1 run.
ET1=1; // ENable the interrupt ( ie)
ES0=1; // enable the seria0 (ie)
SFRPAGE = temp; // Restore SFR page.
}
写得中断处理函数如下:
void Timer1_ISR_handle(void) interrupt 3
{
}//空函数
有人知道原因?