《单片机C语言编程与实例的代码.rar

源代码在线查看: 8-isd4004.lst

软件大小: 280 K
上传用户: 潘内哇
关键词: 单片机 C语言编程 代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				C51 COMPILER V6.20c  8_ISD4004                                                             09/02/2001 15:00:12 PAGE 1   
				
				
				C51 COMPILER V6.20c, COMPILATION OF MODULE 8_ISD4004
				OBJECT MODULE PLACED IN 8-isd4004.OBJ
				COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 8-isd4004.c DEBUG OBJECTEXTEND
				
				stmt level    source
				
				   1          #include 
				   2          
				   3          sbit   SS=P1^0;            				//片选
				   4          sbit   SCLK=P1^1;            			//ISD4004时钟
				   5          sbit   MOSI=P1^2;            			//数据输入
				   6          sbit   MISO=P1^3;            			//数据输出
				   7          sbit   LED=P1^7;            			//指示灯
				   8          sbit   AN=P1^6;            			//执行
				   9          sbit   STOP=P1^5;            			//复位
				  10          sbit   PR=P1^4;            				//PR=1录音,PR=0放音
				  11          sbit   INT=P3^4;            			//中断
				  12          
				  13          void   YS50();
				  14          void   ISDX(unsigned char d);
				  15          void   UP();
				  16          void   STOPP();
				  17          void   DSTOP();
				  18          	
				  19          main()
				  20          {
				  21   1          unsigned char delay;        			//延时参数
				  22   1          unsigned char isdl,isdh;    			//ISD高低位
				  23   1          unsigned char n1;
				  24   1      	
				  25   1          SP=0x10;
				  26   1          P0=0xFF;
				  27   1          P1=0xFF;
				  28   1          P2=0xFF;
				  29   1          P3=0xFF;
				  30   1          EA=0;
				  31   1      lab1:
				  32   1          LED=1;                       			//关指示灯
				  33   1          DSTOP();                     			//ISD掉电
				  34   1          delay=200;
				  35   1          while(AN);                   			//等按AN键
				  36   1          while(delay--);              			//延时
				  37   1          UP();                        				//ISD上电
				  38   1          isdl=isdh=0;                 			//ISD高低位地址置0
				  39   1          if(PR)                       				//PR=1 录音
				  40   1          {
				  41   2      ISDX(isdl);
				  42   2      ISDX(isdl);
				  43   2      ISDX(isdh);
				  44   2      SS=1;
				  45   2      b1:
				  46   2             n1=10;
				  47   2              while(n1--)
				  48   2            YS50();
				  49   2      LED=0;
				  50   2      ISDX(0xB0);
				  51   2      SS=1;
				  52   2      if(INT)
				  53   2      {
				  54   3      while(!AN);
				  55   3      n1=200;
				C51 COMPILER V6.20c  8_ISD4004                                                             09/02/2001 15:00:12 PAGE 2   
				
				  56   3      while(n1--);
				  57   3      LED=1;                    		//关指示灯
				  58   3      STOPP();                  		//停止当前操作
				  59   3      if(STOP)
				  60   3      {
				  61   4      while(!AN);
				  62   4      STOPP();
				  63   4      goto b1;
				  64   4      }
				  65   3      }
				  66   2      else
				  67   2      {
				  68   3      b2:
				  69   3      LED=1;
				  70   3      n1=15;
				  71   3      while(!AN)
				  72   3      {
				  73   4      while(!n1--)
				  74   4      YS50();
				  75   4      LED=0;
				  76   4      n1=15;
				  77   4      while(!AN)
				  78   4      {
				  79   5      while(!n1--)
				  80   5      YS50();
				  81   5      goto b2;
				  82   5      }
				  83   4      }
				  84   3      }
				  85   2      }
				  86   1      else                         			//PR=0 放音
				  87   1      {
				  88   2      while(!AN);
				  89   2      ISDX(isdl);
				  90   2      ISDX((isdh|0xE0)&0xE7);
				  91   2      SS=1;
				  92   2      b3:
				  93   2      LED=0;
				  94   2      ISDX(0xF0);
				  95   2      SS=1;
				  96   2      if(STOP)
				  97   2      {
				  98   3      while(INT);
				  99   3      LED=1;
				 100   3      STOPP();
				 101   3      SS=0;
				 102   3      SCLK=0;
				 103   3      SCLK=1;
				 104   3      if(!MISO)
				 105   3      {
				 106   4      SCLK=0;
				 107   4      SS=1;
				 108   4      STOPP();
				 109   4      if(STOP)
				 110   4      {
				 111   5      while(!AN);
				 112   5      goto b3;
				 113   5      }
				 114   4      }
				 115   3      }
				 116   2      }
				 117   1      SCLK=0;
				C51 COMPILER V6.20c  8_ISD4004                                                             09/02/2001 15:00:12 PAGE 3   
				
				 118   1      SS=1;
				 119   1      STOPP();
				 120   1      goto lab1;
				 121   1      }
				 122          
				 123          /*ISD4004芯片驱动*/
				 124          /********************************50mS延时*********************************/
				 125          void  YS50()
				 126          {
				 127   1      TMOD=1;
				 128   1      TH0=0x3C;                			//50mS延时初值置入
				 129   1      TL0=0xB0;
				 130   1      TR0=1;
				 131   1      while(!TF0);
				 132   1      TF0=0;
				 133   1      TR0=0;
				 134   1      }
				 135          /*ISD3300.4003 SPI写入程序*/
				 136          void  ISDX(unsigned char d)
				 137          {
				 138   1      unsigned char i,j;
				 139   1      SS=0;                      			//开片选
				 140   1      SCLK=0;                    			//时钟SCLK=0
				 141   1      j=d;
				 142   1      for(i=0;i				 143   1      {
				 144   2      if(j&0x01)               			//数据写 MOSI
				 145   2      MOSI=1;
				 146   2      else
				 147   2      MOSI=0;
				 148   2      SCLK=1;                  			//时钟SCLK=1
				 149   2      j=j>>1;
				 150   2      SCLK=0;                  			//时钟SCLK=0
				 151   2      }
				 152   1      }
				 153          
				 154          /*ISD上电*/
				 155          void  UP()
				 156          {
				 157   1      ISDX(20);                 			//发00100XXXXXXXXXXX
				 158   1      SS=1;                     			//关片选
				 159   1      YS50();                   			//50mS延时
				 160   1      YS50();                   			//50mS延时
				 161   1      }
				 162          
				 163          /*停止当前操作*/
				 164          void  STOPP()
				 165          {
				 166   1      ISDX(30);                 			//发 0X110XXX
				 167   1      SS=1;                     			//关片选
				 168   1      YS50();                   			//50mS延时
				 169   1      YS50();                   			//50mS延时
				 170   1      }
				 171          
				 172          /*停止当前操作掉电*/
				 173          void  DSTOP()
				 174          {
				 175   1      ISDX(10);                 			//发0X010XXXXXXXXXX
				 176   1      SS=1;                     			//关片选
				 177   1      YS50();                   			//50mS延时
				 178   1      YS50();                   			//50mS延时
				 179   1      }
				C51 COMPILER V6.20c  8_ISD4004                                                             09/02/2001 15:00:12 PAGE 4   
				
				
				
				MODULE INFORMATION:   STATIC OVERLAYABLE
				   CODE SIZE        =    308    ----
				   CONSTANT SIZE    =   ----    ----
				   XDATA SIZE       =   ----    ----
				   PDATA SIZE       =   ----    ----
				   DATA SIZE        =   ----       3
				   IDATA SIZE       =   ----    ----
				   BIT SIZE         =   ----    ----
				END OF MODULE INFORMATION.
				
				
				C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
							

相关资源