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

📄 isd1700.lst

📁 语音模块程序
💻 LST
字号:
C51 COMPILER V7.06   ISD1700                                                               05/10/2009 22:59:46 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE ISD1700
OBJECT MODULE PLACED IN ISD1700.OBJ
COMPILER INVOKED BY: D:\dujianfei\Keil C\C51\BIN\C51.EXE ISD1700.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /*
   2          实验说明:
   3          接线:
   4            1、将模块上的INT与CPU板上的INT0相连;
   5            2、将模块上的DO与CPU板上的P11相连;
   6            3、将模块上的DI与CPU板上的P12相连;
   7            4、将模块上的CLK与CPU板上的P10相连;
   8            5、将模块上的SS与CPU板上的P14相连;
   9            6、将试验箱上开关KK1的输出K1与CPU板上的P15相连;
  10            7、将试验箱上开关KK2的输出K2与CPU板上的P16相连;
  11            8、将试验箱上开关KK3的输出K3与CPU板上的P17相连;暂时不用接。
  12          实验过程:
  13            检查接线正确无误后,加电,运行程序ISD1700,将开关KK1、KK2、KK3拨到低电平侧(L侧)
  14          先将KK1拨到H侧并对MIC讲话,结束后将开关KK1拨回L侧。将拨码开关KK2拨到H侧,开始放音,直至结束。
  15          如果想重放,先将开关KK2拨到L侧,在拨到H侧,则重复放音。
  16          
  17          */
  18          #include    <reg51.h>
  19          //sbit          INT      =      P1^0;   //Port to Receive interrupt signal from ISD1700
  20          sbit            DO       =      P1^1;    //Port to Receive data from ISD1700
  21          sbit            DI       =      P1^2;    //Port to Sent data to ISD1700
  22          sbit            CLK      =      P1^0;    //Output SPI clock
  23          sbit            SS       =      P1^4;    //Reset this port to enable SPI of ISD1700
  24          sbit            rec      =      P1^5;    //Record from Line In or Mic selected by sel
  25          sbit            play =  P1^6;    //Playing while end
  26          sbit            sel      =      P1^7;    //select source of audio
  27          unsigned char PU_cmd[]          = {0x01,0x00};          //Power on
  28          unsigned char STOP_cmd[]        = {0x02,0x00};          //Stop current operation
  29          unsigned char RESET_cmd[]       = {0x03,0x00};          //Stop current operation
  30          unsigned char CLR_INT_cmd[] = {0x04,0x00};              //clearn INT to zero
  31          unsigned char RD_STA_cmd[]      = {0x05,0x00,0x0};              //Read status byte
  32          unsigned char RD_PLY_PTR_cmd[]  = {0x06,0x00,0x0,0x0};          //Read play point
  33          unsigned char PD_cmd[]          = {0x07,0x00};          //Power off
  34          unsigned char RD_REC_PTR_cmd[]  = {0x08,0x0,0x0,0x0};   //Read record point
  35          unsigned char DEVID_cmd[]               = {0x09,0x0,0x0};               //Read device ID
  36          unsigned char PLAY_cmd[]                = {0x40,0x0};                   //begin to play here 
  37          unsigned char REC_cmd[]                 = {0x41,0x0};                   //begin to record here
  38          unsigned char ERASE_cmd[]               = {0x42,0x0};                   //Erase the current sigment
  39          unsigned char G_ERASE_cmd[]     = {0x43,0x0};                   //Erase all chip
  40          unsigned char RD_APC_cmd[]              = {0x44,0x0,0x0,0x0};   //Read register APC
  41          unsigned char WR_APC1_dir_cmd[]         = {0x45,0x7,0x4};               //Enable mode direct in SPI
  42          unsigned char WR_APC1_mic_cmd[]         = {0x45,0x47,0x4};              //Disable mode direct in SPI
  43          unsigned char WR_APC2_cmd[]     = {0x65};                               //Write config data to APC,refer to function WriteApc(unsigned i
             -nt dat)
  44          unsigned char FWD_cmd[]                 = {0x48,0x0};                   //Move the current point to next
  45          unsigned char CHK_MEM_cmd[]     = {0x49,0x0};                   //Check the loop memory
  46          unsigned char EXTCLK_cmd[]              = {0x4a,0x0};                   //Enable the ext clock
  47          bit             idle = 1;               //Chip is in idle status
  48          bit             recflag = 0;    //flag of record
  49          bit     audinflag = 0;  //flag  mode audio in 
  50          unsigned char *pStatus;  //Status of chip
  51          void Delay(unsigned int time)
  52            {
  53   1         while(time-->0);
  54   1        }
C51 COMPILER V7.06   ISD1700                                                               05/10/2009 22:59:46 PAGE 2   

  55          void SpiIni(void)                       //Initialize SPI port          
  56            {
  57   1         SS = 1;
  58   1         CLK = 1;
  59   1         DI = 0;
  60   1         Delay(10);
  61   1        }
  62          unsigned char WriteByte(unsigned char dat)      //write a byte to ISD1700, Read a byte from ISD
  63            {
  64   1         char num = 8;
  65   1         unsigned char tmp = 0;
  66   1         DO = 1;
  67   1         while(num-->0)
  68   1           {
  69   2            CLK = 0;
  70   2                Delay(20);
  71   2                DI = (dat&0x1)?1:0;
  72   2                dat >>=1;       
  73   2            tmp >>= 1;          
  74   2                tmp |= (DO == 0) ? 0x80:0x0;
  75   2                Delay(20);
  76   2            CLK = 1;
  77   2            Delay(80);
  78   2               }
  79   1         //Delay(1000);
  80   1         return tmp;
  81   1        }
  82          
  83          void Write2ISD1700(unsigned char num,unsigned char * pBuff,unsigned char *pReceive)  //
  84            {
  85   1         SS = 0;
  86   1         while(num-->0)
  87   1           {
  88   2                *(pReceive++) = WriteByte(*(pBuff++));
  89   2               }
  90   1         SS = 1;
  91   1        }
  92          void Ext0Inter(void) interrupt 0
  93            {
  94   1         unsigned char IntClrCmd[] = {0x04,0x0};
  95   1         idle = 1;
  96   1         Write2ISD1700(2,IntClrCmd,pStatus);   //Clearn INTERRUPT and EOM flag
  97   1        }
  98          void PlayCurrent(void)  //Start to play at current segment
  99            {
 100   1         while(!idle); 
 101   1         idle = 0;
 102   1         Write2ISD1700(2,PLAY_cmd,pStatus);  //Start to play at current segment
 103   1        }
 104          void Record(void)  //Start to play at current segment
 105            {
 106   1         while(!idle); 
 107   1         idle = 0;
 108   1         recflag = 1;
 109   1         Write2ISD1700(2,REC_cmd,pStatus);  //Start to play at current segment
 110   1        }
 111          void EraseAll(void)  //Start to play at current segment
 112            {
 113   1         while(!idle); 
 114   1         idle = 0;
 115   1         Write2ISD1700(2,G_ERASE_cmd,pStatus);  //Start to play at current segment
 116   1        }
C51 COMPILER V7.06   ISD1700                                                               05/10/2009 22:59:46 PAGE 3   

 117          void Stop(void)
 118            {
 119   1         Write2ISD1700(2,STOP_cmd,pStatus);  //Start to play at current segment   
 120   1         recflag = 0;
 121   1        }
 122          void AudioSeclect(bit s)
 123            {
 124   1         if(s) Write2ISD1700(3,WR_APC1_dir_cmd,pStatus);
 125   1         else  Write2ISD1700(3,WR_APC1_mic_cmd,pStatus);
 126   1         audinflag = 0;
 127   1        }
 128          void main(void)
 129            {
 130   1          unsigned char *pDevid,Cmd[] = {0xa5};
 131   1         bit selbak = 0,selchange = 0;
 132   1         SpiIni();
 133   1         IT0 = 1; EX0 = 1; EA=1;
 134   1         Write2ISD1700(2,RESET_cmd,pStatus);    //Reset the chip
 135   1         Write2ISD1700(2,PU_cmd,pStatus);       //Power on
 136   1         Write2ISD1700(3,DEVID_cmd,pDevid);
 137   1         EraseAll();
 138   1         while(1) 
 139   1           {
 140   2               /*
 141   2                if(sel != selbak) 
 142   2                  {
 143   2                       selbak = sel;
 144   2                       selchange = 1;
 145   2                      }
 146   2                */
 147   2                if(rec&&!play) 
 148   2                  {
 149   3                      /*
 150   3                       if(selchange)
 151   3                         {
 152   3                          AudioSeclect(sel);
 153   3                              selchange = 0;
 154   3                         }
 155   3                       */
 156   3                       Record();
 157   3                       while(rec);
 158   3                      }
 159   2                if(recflag) Stop();
 160   2            if(play&&!rec)
 161   2                  {
 162   3                       PlayCurrent();
 163   3                       while(play);
 164   3                      }
 165   2               }
 166   1        }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    535    ----
   CONSTANT SIZE    =      3    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     52      13
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      3       3
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -