日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 基于51單片機的電子測速里程防盜報警器設計

          基于51單片機的電子測速里程防盜報警器設計

          作者: 時間:2012-09-10 來源:網絡 收藏

          //************************************************************

          本文引用地址:http://yuyingmama.com.cn/article/170899.htm

          //標題:4乘4鍵盤的輸入函數
          // 函數描述: char gotkey(void)
          // 從4*4小鍵盤輸入數據,返回0~9,及其它數據.
          //***********************************************************
          //時間遲延函數
          //*********************************************************
          void delay (void)
          {
          unsigned char i,j;
          for(i=0;i5;i++)
          for(j=0;j255;j++);
          }
          //*************************************************
          //檢查是否有按鍵按下
          //*************************************************
          char keypad_scan()
          {
          char key,i;
          p2=0xF0;
          while(p2!=0XF0);
          do{
          for(i=0;i=3;i++)
          { p2=ksp;
          if(p2!=ksp)
          {
          delay();
          key=p2;
          if(key!=ksp)
          {
          return(key);
          }
          }
          }
          }while(1);
          }
          //***************************************
          //取得鍵值
          //***************************************
          char gotkey()
          {
          char temp,i;
          temp=keypad_scan();
          for(i=0;i=15;i++)
          {
          if(temp==key_code)
          return(i);
          }
          }


          //**************************************
          //93c66驅動程序
          //**************************************
          //********************************************

          unsigned char read_byte(int address)
          {int i, command;
          unsigned char temp;
          CS=1;
          command=(READ|address);
          write_command(command);
          for(i=0;i8;i++)
          {SK=1;
          SK=0;
          temp=(temp1);
          if(DO==1)
          temp=(temp|0X01);
          }
          CS=0;
          return(temp);
          }

          //**********************************************

          void write_enable()
          {int command;
          CS=1;
          command=EWEN;
          write_command(command);
          CS=0;
          }

          //***********************************************

          void write_disable()
          {int command;
          CS=1;
          command=EWDS
          write_command(command);
          CS=0;
          }

          //************************************************

          void write_byte(int address,unsigned char write_date)
          {int i,command;
          write_enable();
          CS=1;
          command=(WRITE|address);
          write_command(command);
          for(i=0;i8;i++)
          {if(write_date0X80)}
          DI=1;
          elae
          DI=0;
          SK=1;
          SK=0;
          write_date=(write_data1);
          }
          check_busy();
          write_disable();
          }

          //*************************************************

          void write_command(int command)
          {int i;
          command=(commandshiftbit);
          for(i=0;i12;i++)
          {if(command0X8000)
          DI=1;
          else
          DI=0;
          SK=1;
          SK=0;
          command=(command1);
          }
          }

          //***********************************************

          void check_busy(void)
          {CS=0;
          CS=1;
          while(DO==0);
          }

          //******************************************
          //標題:ISD4004驅動法程序
          //功能:語音選段播放
          //******************************************
          void delay(unsigned int time) //延遲n微秒
          {
          while(time!=0)
          {
          time-- ;
          }
          }
          void delayms(unsigned int time) //延遲n毫秒
          { TMOD=0x01;

          for(time;time>0;time--)
          {
          TH0=0xfc;
          TL0=0x18;
          TR0=1;
          while(TF0!=1)
          {;}
          TF0=0;
          TR0=0;
          }

          }

          //************************************
          //ISD4004 spi串行發(fā)送子程序,16位數據
          //************************************
          void spi_send(unsigned char isdx)
          { unsigned char isx_counter;
          SS=0; //ss=0,打開spi通信端
          SCLK=0;
          for(isx_counter=0;isx_counter8;isx_counter++)
          //先發(fā)低位再發(fā)高位,依次發(fā)送。
          { if ((isdx0x01)==1)
          MOSI=1;
          else
          MOSI=0;
          isdx=isdx>>1;
          SCLK=1;
          delay(2);

          SCLK=0;
          delay(2);
          }
          }

          //*******************************
          //發(fā)送stop指令
          //*******************************
          void isd_stop(void)
          { delay(10);
          spi_send(0x30);
          SS=1;
          delayms(50);
          }
          //*******************************
          //發(fā)送上電指令,并延遲50ms
          //*******************************
          void isd_pu(void)
          { delay(10);
          SS=0;
          spi_send(0x20);
          SS=1;
          delayms(50);
          }
          //*******************************
          //發(fā)送掉電指令,并延遲50ms
          //*******************************

          void isd_pd(void)
          { delay(10);

          spi_send(0x10);
          SS=1;
          delayms(50);
          }


          //*******************************
          //發(fā)送分段語音setplay指令
          //*******************************
          void isd_setplay(unsigned char adl,unsigned char adh)
          {
          isd_pd();
          delayms(1);
          spi_send(adl);
          delay(2);
          spi_send(adh);
          delay(2);
          spi_send(0xe0);
          SS=1;
          spi_send(0xf0);
          SS=1;
          if(ISD_INT==0)
          isd_stop();
          isd_pd();
          }



          評論


          相關推薦

          技術專區(qū)

          關閉