⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.c.bak

📁 w77E58开发的具备蓝牙功能的GPS导航仪
💻 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 + -