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

📄 isd4003.lst

📁 这是语音芯片ISD4004的操作代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V3.96,  SN-83203013  ISD4003                                                  04/24/03  19:05:28  PAGE 1   


DOS C51 COMPILER V3.96, COMPILATION OF MODULE ISD4003
OBJECT MODULE PLACED IN ISD4003.OBJ
COMPILER INVOKED BY: C:\C51\BIN\C51.EXE ISD4003.C DB SYMBOLS LA

stmt level    source

   1          /*************************************************************/
   2          /*                          isd4003.c                        */
   3          /*           2001.10.25 designed by Wang XuanQiang           */
   4          /*************************************************************/
   5          
   6          #pragma CODE DEBUG SYMBOLS OBJECTEXTEND
   7          #include <reg51.h>
   8          #include <absacc.h>
   9          #include <isd4003.h>
  10          
  11          void delay (void)  /* 延时 */
  12          {
  13   1      		uint xdata  i,j;  /*delay 1/2ms*/
  14   1              for(i = 0; i < 1000; i++)
  15   1              {
  16   2                  j = (i * 2) / 2;
  17   2              }
  18   1      }
  19          
  20          void transmit_serial (void) /* */
  21          {
  22   1      	uchar xdata i;
  23   1        	for (i = 0;i < 4;i++)
  24   1        	{
  25   2        	     	SBUF = transmit_buf[i];  
  26   2        	        while (TI==0);
  27   2        	        TI=0;
  28   2        	}
  29   1      }
  30          
  31          void isd4003_write (uint command) /* 发送命令 */
  32          {
  33   1              uint i,j,k;
  34   1              i = command;
  35   1              S_CS = 0;
  36   1              j = 0;
  37   1              S_CLK = 0;
  38   1              for(k = 0;k < 16;k++)
  39   1              {
  40   2              	S_IN = i & 0x01;
  41   2              	j = 0;
  42   2              	S_CLK = 1;
  43   2              	j = 0;
  44   2              	S_CLK = 0;
  45   2              	i = (i >> 1);
  46   2              }
  47   1              S_CS = 1;
  48   1              delay();
  49   1      }
  50          
  51          void isd4003_read (void) /* 读取命令 */
  52          {
  53   1              uchar xdata i,j;
  54   1              S_CS = 0;
  55   1              j = 0;
C51 COMPILER V3.96,  SN-83203013  ISD4003                                                  04/24/03  19:05:28  PAGE 2   

  56   1              temp = 0;
  57   1              S_CLK = 0;
  58   1              for(i = 0;i < 16;i++)
  59   1              {
  60   2              	S_CLK = 1;
  61   2              	j = 0;
  62   2              	S_CLK = 0;
  63   2              	if(S_OUT)
  64   2              		temp = (temp << 1) + 1;
  65   2              	else
  66   2              		temp = (temp << 1);
  67   2              	S_CLK = 0;
  68   2              }
  69   1              S_CS = 1;
  70   1              temp = (temp >> 4) & 0x0fff;
  71   1              r_addr = 0;
  72   1              for(i = 0;i < 10;i++)
  73   1              {
  74   2              	temp = temp >> 1;
  75   2              	c_flag = temp & 0x01;
  76   2              	if(c_flag == 0x01)
  77   2              		r_addr = (r_addr << 1) + 1;
  78   2              	else
  79   2              	        r_addr = (r_addr << 1);
  80   2              } 
  81   1              delay();
  82   1      } 
  83          
  84          void init_manage(void)
  85          {
  86   1      	uint xdata temp2;
  87   1      	if((init_flag == 1) && (duan_num != 7))
  88   1      	{
  89   2      		temp2 = 0x2000;
  90   2      		isd4003_write(temp2);
  91   2      		temp2 = duan_addr[duan_num];
  92   2      		temp2 = temp2 + 0xe000;
  93   2      		isd4003_write(temp2);
  94   2      		temp2 = 0xf000;
  95   2      		isd4003_write(temp2);
  96   2      		PLAY_LED = 0;	
  97   2      		duan_num++;
  98   2      		
  99   2      	}
 100   1      	else
 101   1      	{
 102   2      		init_flag = 0;
 103   2      		duan_num = 0;
 104   2      		transmit_buf[0] = 0xbb;
 105   2          	transmit_buf[1] = 0x0;
 106   2          	transmit_buf[2] = 0x0;
 107   2          	transmit_buf[3] = 0x0;
 108   2          	transmit_serial();	
 109   2              
 110   2          	c_temp = 0x1000;
 111   2      		isd4003_write(c_temp);
 112   2      	
 113   2      		isd4003_read();
 114   2      	
 115   2      		delay();
 116   2      		delay();
 117   2      		delay();
C51 COMPILER V3.96,  SN-83203013  ISD4003                                                  04/24/03  19:05:28  PAGE 3   

 118   2      	
 119   2      		transmit_buf[0] = 0xbb;
 120   2          	transmit_buf[1] = 0x1;
 121   2          	transmit_buf[2] = (r_addr >> 8);
 122   2          	transmit_buf[3] = (r_addr & 0xff);
 123   2          	transmit_serial();
 124   2      
 125   2      		PLAY_LED = 1;
 126   2      		REC_LED = 1;
 127   2      	}
 128   1      }
 129          
 130          
 131          void manage_command (void) /**/
 132          {
 133   1      	uchar xdata temp1;
 134   1      	uint xdata temp2;
 135   1      	if(command_data[0] == 0xaa)	
 136   1      	{
 137   2      		temp1 = command_data[1];
 138   2      		switch (temp1)
 139   2      		{
 140   3      			case 0: /* 从设定地址开始放音   */
 141   3      				temp2 = 0x2000;
 142   3      				isd4003_write(temp2);
 143   3      				temp2 = ((command_data[2] << 8) + command_data[3]) & 0x7ff;
 144   3      				temp2 = temp2 + 0xe000;
 145   3      				isd4003_write(temp2);
 146   3      				temp2 = 0xf000;
 147   3      				isd4003_write(temp2);
 148   3      				PLAY_LED = 0;
 149   3      			break;
 150   3      			case 1: /* 快进到某一段         */
 151   3      				temp2 = 0x2000;
 152   3      				isd4003_write(temp2);
 153   3      				temp2 = duan_addr[duan_num];
 154   3      				temp2 = temp2 + 0xe000;
 155   3      				isd4003_write(temp2);
 156   3      				temp2 = 0xf000;
 157   3      				isd4003_write(temp2);
 158   3      				PLAY_LED = 0;	
 159   3      				duan_num++;
 160   3      				init_flag = 1;
 161   3      			break;
 162   3      			case 2: /* 从设定地址开始录音   */
 163   3      				temp2 = 0x2000;
 164   3      				isd4003_write(temp2);
 165   3      			    temp2 = ((command_data[2] << 8) + command_data[3]) & 0x7ff;
 166   3      				temp2 = temp2 + 0xa000;
 167   3      				isd4003_write(temp2);
 168   3      				temp2 = 0xb000;
 169   3      				isd4003_write(temp2);
 170   3      				REC_LED = 0;
 171   3      			break;
 172   3      			case 3: /* 读取一个段的结束地址 */
 173   3      			        isd4003_read();
 174   3      			break;
 175   3      			case 4: /* 芯片上电             */
 176   3      				temp2 = 0x2000;
 177   3      				isd4003_write(temp2);
 178   3      				transmit_buf[0] = 0xbb;
 179   3                      transmit_buf[1] = 0x0;
C51 COMPILER V3.96,  SN-83203013  ISD4003                                                  04/24/03  19:05:28  PAGE 4   

 180   3                      transmit_buf[2] = 0x0;
 181   3                      transmit_buf[3] = 0x0;
 182   3                      transmit_serial();
 183   3      			break;
 184   3      			case 5: /* 停止当前操作         */
 185   3      				init_manage();
 186   3      			break;
 187   3      			default:
 188   3      				temp2 = 0x1000;
 189   3      				isd4003_write(temp2);
 190   3      			break;                        
 191   3      		}
 192   2      	}	
 193   1      }
 194          
 195          void extract_command (void)/**/
 196          {
 197   1      	uchar xdata temp;
 198   1      	while(c_bottom != c_top)
 199   1      	{
 200   2      		for(temp = 0;temp < 4;temp++)
 201   2      			command_data[temp] = command_buf[((temp + c_top) & 0xff)];
 202   2      		manage_command();
 203   2      		c_top = (c_top + 4) & 0xff;
 204   2      	}	
 205   1      }
 206          
 207          void init_var () /* */
 208          { 
 209   1      	uint xdata temp;
 210   1      	duan_num = 0;
 211   1      	c_bottom = 0;
 212   1      	c_top = 0;
 213   1      	ms50_num = 0;
 214   1      	flag_50ms = 0;
 215   1      	flag_1s = 0;
 216   1      	c_flag = 0;
 217   1      	r_addr = 0;
 218   1      	temp = 0;
 219   1      	init_flag = 0;
 220   1      	for(temp = 0;temp < 4;temp++)
 221   1      	{
 222   2      		command_data[temp] = 0;
 223   2      		transmit_buf[temp] = 0;
 224   2      	}
 225   1      	for(temp = 0;temp < 256;temp++)
 226   1      		command_buf[temp] = 0;        
 227   1      	
 228   1      }
 229          
 230          void serial () interrupt 4 using 3  /*串口中断*/
 231          {
 232   1      	uchar xdata temp;
 233   1              EA = 0;
 234   1              if(RI)
 235   1              {
 236   2      	    RI = 0;
 237   2      	    temp=SBUF;
 238   2      	    command_buf[c_bottom] = temp;
 239   2      	    c_bottom = (c_bottom + 1) & 0xff;
 240   2              }
 241   1              EA = 1;
C51 COMPILER V3.96,  SN-83203013  ISD4003                                                  04/24/03  19:05:28  PAGE 5   

 242   1      }
 243          
 244          void intt() interrupt 1 using 2 /*定时器0中断处理 */
 245          {
 246   1      		xdata uint m;
 247   1      		EA = 0;
 248   1              TH0=0xa0;
 249   1              TL0=0x00;
 250   1              ms50_num++;
 251   1              flag_50ms = 1;
 252   1              if(ms50_num > 10)
 253   1              {
 254   2              	flag_1s = 1;
 255   2              	ms50_num = 0;
 256   2              }
 257   1              EA=1;
 258   1      }
 259          
 260          void main ()
 261          {
 262   1      	IE = 0;
 263   1      	P1 = 0xff;
 264   1      	P1 = 0x0;
 265   1      	P1 = 0xff;
 266   1      	
 267   1      	S_IN = 0;
 268   1      	S_CS = 1;
 269   1      	S_CLK = 0;
 270   1      	
 271   1      	init_var();
 272   1      	
 273   1      	c_temp = 0x2000;
 274   1      	isd4003_write(c_temp);
 275   1      	delay();
 276   1      	
 277   1          SCON = 0x50;/* 设置串口 */
 278   1         	TMOD = 0x21;/* SCON 工作方式1 10位异步收发 允许接收串口数据 */
 279   1         	TCON = 0x69;/* 定时器1为工作方式2  自动重装载8位定时器 定时器0为工作方式1 16位定时器 */
 280   1         	TH1 =  0xfa;/* TCON 定时器1启动 定时器1溢出标志置1 外部中断0,1置1 */
 281   1         	TL1 =  0xfa; /* TH1 0xe8h 1.2k  0xfa 4.8k 0xfd 9.6k */
 282   1         	PCON = 0;
 283   1         	TH0 = 0xa0;
 284   1         	TL0 = 0x00;
 285   1         	TCON = 0x50;/* 定时器0,1同时启动 */
 286   1          IE = 0x92;
 287   1          while(1)
 288   1          {
 289   2              if(flag_50ms == 1)
 290   2              {
 291   3              	flag_50ms = 0;
 292   3              	if(P_INT == 0)

⌨️ 快捷键说明

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