当前位置:首 页 --> 技术分享
基于PIC16F886 的ISD2100语音IC的驱动代码
发布时间:2011/8/8 18:01:00 来源:
在线咨询:
给我发消息
张代明 3003290139
给我发消息
姚红霞 3003214837
给我发消息
李湘宁 2850985550
13713728695

#include <stdio.h>
#include <pic.h>
#include<time.h>
#include "usart.h"
__CONFIG(0x3FD4); //看门狗关,内部RC振荡,GO0/GP1做I/O,不加密,MCLR脚做复位
#define   _XTAL_FREQ  8000000 /* A simple demonstration of serial communications which
* incorporates the on-board hardware USART of the Microchip PIC16Fxxx series of devices.
* 空闲时保证sck高电平
* 上升沿采样数据
* 公司 大联大集团品佳集团 王鹤
* 时间 20100829
* UART 硬件 SPI采用软件,没有SPI地址
* 后续考虑 软件UART*/

//此处CS LOW有效
#define   TRUE  0
#define   FALSE  1
#define   ISD2100_CS       RC2   
#define   ISD2100_CS_TRIS       TRISC2
#define   ISD2100_clk      RC3
#define   ISD2100_clk_TRIS      TRISC3
#define   ISD2100_DO       RC5
#define   ISD2100_DO_TRIS    TRISC5
#define   ISD2100_SI       RC4
#define   ISD2100_SI_TRIS        TRISC4
#define   ISD2100_INTB       RB0
#define   ISD2100_INTB_TRIS    TRISB0
#define   ISD2100_RST       RB1
#define   ISD2100_RDY       RB2
#define   ISD2100_RDY_TRIS  TRISB2
unsigned int Rdata ;
unsigned char RdataBuf[10] ;
unsigned char SenddataBuf[10] ;
void Send8BitData(unsigned char cmd1)
{
unsigned char n=8;
ISD2100_CS = TRUE;
for (n = 0; n<8 ;n++)
{
   ISD2100_clk = 0;
   if((cmd1 & 0x80) == 0x80)
  ISD2100_DO = 1 ;
      else  ISD2100_DO = 0 ;
  __delay_us(1);
    ISD2100_clk = 1;
  __delay_us(1);
        cmd1=cmd1<<1;
}
ISD2100_CS = FALSE;
}
void SendData(unsigned char SendCount)
{
unsigned char n,m;
//ISD2100_clk = 1;
    for(m=0;m<SendCount;m++)
    {      //while(!ISD2100_RDY);
  for (n = 0; n<8 ;n++)
  { ISD2100_clk = 0;
        if((SenddataBuf[m] & 0x80) == 0x80)
        ISD2100_DO = 1 ;
          else  ISD2100_DO = 0 ;
   __delay_us(1);
     ISD2100_clk = 1;
   __delay_us(1);
   SenddataBuf[m]=SenddataBuf[m]<<1;
  }
}
ISD2100_clk = 1;
}
/***************************************
发送16bit给spiEEPROM数据程序
如发送0x1234 给eeprom
调用格式为:   Send16BitData(0x1234);
****************************************/
void Send16BitData(unsig                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                the USART - settings defined in usart.h
// Output a message to prompt the user for a keypress
printf("\rPress a key and I will echo it back:\n");
while(1){
  input = getch(); // read a response from the user
        printf("\rI detected [%c]",input); // echo it back
  if(input == 'q')
  {
   Send8BitData(0x10);   
   printf("P_Up\n"); // echo it back
  }
  if(input == 'w')
  {
   Send8BitData(0x12);      
   printf("P_Down\n"); // echo it back
  }
  if(input == 'e')
  {
   SenddataBuf[0]=0x14;
       SendData(1);   
   printf("RESET\n");//Set8BitData(0x14);    // echo it back
  }
  if(input == 'r' | input == 'f')
  {
      ISD2100_clk = 1;
   ISD2100_CS = TRUE;
   SenddataBuf[0]=0xa4;
   SenddataBuf[1]=0x00;
   if(input == 'r')
   SenddataBuf[2]=i++;
   if(input == 'f')
   SenddataBuf[2]=i--;
   SenddataBuf[3]=0x00;
   SenddataBuf[4]=0x04;
       SendData(5);
      ISD2100_CS = FALSE;
  printf("VP index = %c%c\n",i/10+48,i%10+48); // echo it back
}
if(input == '1')//read device   两种方法都通过测试
{
     ISD2100_clk = 1;
  ISD2100_CS = TRUE;
     READ_ID();    //ok         方法1
// Send8BitData(0x48); //read ID  方法2
    //   ReceiveData(4) ;       //read ID  方法2
     ISD2100_CS = FALSE;

  printf("Device ID=%x%x-%x%x-%x%x-%x%x\n", RdataBuf[0]/16,RdataBuf[0]%16,
                                      RdataBuf[1]/16,RdataBuf[1]%16,
                                      RdataBuf[2]/16,RdataBuf[2]%16,
                                     RdataBuf[3]/16,RdataBuf[3]%16);
}
}
}

以上代码经测试也可用于如 ISD3800/ISD3900等数字式 语音录放IC

 
    您可能对以下产品感兴趣  
产品型号 功能介绍 兼容型号 封装形式 工作电压 备注
 
深圳市永阜康科技有限公司 粤ICP备17113496号 服务热线:0755-82863877 手机:13242913995