?? util.c.bak
字號:
/* YuanGao electronic designe co.ldt
(c) Copyright 2002,2003, All Rights Reserved */
#include <w77e58.h>
#include "global.h"
#include "util.h"
uchar idata SysTimer;
uchar idata _timer0=0; /* timer0 interrupt counter, use this counter to adjust timeout counters period */
#define TIMEOUT_FACTOR 3 /**17**/ /* timeout factor x 1.5ms (timer0 period) = actual timeout period */
/***************************************************************************
* Interrupt, set for falling edge of IE0 pin,use timer0 detect plus width *
****************************************************************************/
void ISR_INT0(void) interrupt 0 using 1
{
;
}
void ISR_Timer0(void) interrupt 1 using 2
{
TH0 = 0xf7;
TL0 = 0x60;
TR0 = 1;
/* count down timeout counters */
if( _timer0 < TIMEOUT_FACTOR )
_timer0++;
else
{
_timer0 = 0;
if(SysTimer) SysTimer--;
}
}
void ISR_INT1(void) interrupt 2 using 1
{
;
}
/**************************************************************************
* Timer1 for 1.5ms interrupt
**************************************************************************/
void ISR_Timer1(void) interrupt 3 using 1
{
#if 0
TH1 = 0xf7; /* 0xf7 */
TL1 = 0; /* 0x0 */
TR1 = 1;
/* count down timeout counters */
if( _timer0 < TIMEOUT_FACTOR )
_timer0++;
else
{
_timer0 = 0;
if(DSA_timer) DSA_timer--;
}
#endif
;
}
/**************************************************************************
* Timer2 for 2ms interrupt
**************************************************************************/
void ISR_Timer2(void) interrupt 5 using 1
{
;
}
/**************************************************************************
* Init system
**************************************************************************/
void CPU_init(void)
{
#if 0
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 */
TR1 = 1; /* timer 1 run */
ES = 1; REN=1; EA=1; SM2=1; //SM2=1時收到的第9位為1才置位RI標志
TMOD |=0x01; //th1 auto load 2X8,th0 1X16
TH0=31; TL0=0; //X 32 =1S
TR0=1; //ET0=1;
#endif
//system init ,其中串口0用定時器2,串口1用定時器1
//串口1的設置
IE=0x90; //允許總中斷和串口0的中斷
TMOD=0x21; //定時器1工作在模式2,定時器0工作在模式1
TL1=0xf4; //baud rate=2400
TH1=0xf4;
SCON1=0x58; //工作在模式1,允許接收
PCON=0x00; // SM0=0 SM1=1 在10位異步收發模式 SMOD=0 溢出速率/32
ES1=1; //串口1中斷允許
SCON=0x58; //工作在模式1,接收允許
T2CON=0x30; //用定時器2做串口0的波特率發生器
RCAP2H=0xff; // 11.0592M晶振下,baud rate=2400
RCAP2L=0x70;
TR2=1;
TR1=1;
}/*end CPU_system_init*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -