messii 发表于 2011-3-14 13:35:09

急。。。请教大虾关于ISD1760的程序问题~~不知道编的程序错在哪

程序如下
#include<reg52.h>
#include<sound.h>
#include<isd1700.h>
#defineuchar unsigned char
#defineuintunsigned int

sbit ISD_SS=P0^7;
sbit ISD_MISO=P0^4;
sbit ISD_MOSI=P0^5;
sbit ISD_SCLK=P0^6;       

sbit RUN_LED=P1^0;       

uchar data ISD_COMM_RAM;
uchar data ISD_COMM_RAM_C;
uchar data *isd_comm_ptr;
uchar data *back_data_ptr;


voiddelay(int x);
voidrest_isd_comm_ptr(void);
uchar T_R_comm_byte( uchar comm_data );
void isd1700_par2_comm(uchar comm_par, uint data_par);
void isd1700_Npar_comm(uchar comm_par,comm_byte_count); //no parameter comm
void isd1700_7byte_comm(uchar comm_par, uint star_addr, uint end_addr);
voidspi_pu (void);
voidspi_stop (void);

voidinit(void);
voidPlaySoundTick(ucharnumber);

/***********器件初始化****************************/
voidinit(void)
{          
        ISD_MOSI=0;   //isd1700 spi control line init
        spi_pu();                //ISD语音芯片上电
        RUN_LED=0;
}

voidspi_pu (void)
      {
               ISD_SS=0;
         isd1700_Npar_comm(ISD1700_PU,2);   
               ISD_SS=1;
      }                          


voidspi_stop (void)
      {
               ISD_SS=0;
         isd1700_Npar_comm(ISD1700_STOP,2);      //isd1700 spi power up
               ISD_SS=1;
      }

void rest_isd_comm_ptr(void)
      {
             isd_comm_ptr=ISD_COMM_RAM;
         back_data_ptr=ISD_COMM_RAM_C;
      }

void isd1700_Npar_comm (uchar comm_par,comm_byte_count)//no parameter comm
       {   
             uchar i;
               i=0;
               ISD_COMM_RAM=comm_par;
               isd_comm_ptr=&ISD_COMM_RAM;
               do{
                     *isd_comm_ptr++=NULL;
                  }while(++i<comm_byte_count-1);

               rest_isd_comm_ptr();               
         i=0;
         do{
             *back_data_ptr++=T_R_comm_byte(*isd_comm_ptr++);
             i++;
         }while(i<comm_byte_count);
          }

void isd1700_7byte_comm(uchar comm_par, uint star_addr, uint end_addr)
       {
         uchar i;
             ISD_COMM_RAM=comm_par;
               ISD_COMM_RAM=NULL;
               ISD_COMM_RAM=star_addr;
         ISD_COMM_RAM=star_addr>>8;
         ISD_COMM_RAM=end_addr;
         ISD_COMM_RAM=end_addr>>8;
         ISD_COMM_RAM=NULL;
         rest_isd_comm_ptr();               
         i=0;
         do{
             *back_data_ptr++=T_R_comm_byte(*isd_comm_ptr++);
             i++;
         }while(i<=7);
       }


uchar T_R_comm_byte( uchar comm_data )
      {
         uchar bit_nuber;
               uchar temp;
               bit_nuber=0;
               temp=0;
               do{
                     ISD_SCLK=0;
             delay(1);
                     if((comm_data>>bit_nuber&0x01)!=0)
                {ISD_MOSI=1;}
             else
                          {ISD_MOSI=0;}
             if(ISD_MISO)
                           {temp=(temp>>1)|0x80;}
             else
                           {temp=temp>>1;}
             ISD_SCLK=1;
             delay(1);
                       
                        }while(++bit_nuber<=7);
         ISD_MOSI=0;
                  return (temp);
          }

void delay(int x)
      {
             uchar i;
               for(; x>=1; x--)
                  {for(;i<=20;i++);}
      }

void delay_isd(uint time)
{
        while(time--!=0);
}


/*****************获取语音段始末地址*****************/
void GetSound(uchar soundtick)
{
        ISD_SS=0;
        switch(soundtick)
        {
                case 0:{ isd1700_7byte_comm(ISD1700_SET_PLAY|ISD_LED, sound_0A, sound_0B); }break;
                case 1:{ isd1700_7byte_comm(ISD1700_SET_PLAY|ISD_LED, sound_1A, sound_1B); }break;
          case 2:{ isd1700_7byte_comm(ISD1700_SET_PLAY|ISD_LED, sound_2A, sound_2B); }break;
          case 3:{ isd1700_7byte_comm(ISD1700_SET_PLAY|ISD_LED, sound_3A, sound_3B); }break;
          default: break;
   }
        ISD_SS=1;
}

/*****************播放指定的语音段*****************/
void PlaySoundTick(ucharnumber)
{
          spi_stop ();
          delay_isd(30000);
      GetSound(number);
}

/***********主函数****************************/
void main(void)
{
        init();                                                  //器件初始化
        while(1)
        {
                        PlaySoundTick(0);        //播放0
                        delay(30000);
                        PlaySoundTick(1);        //播放1
                        delay(30000);
                        PlaySoundTick(2);        //播放2
                        delay(30000);
                        PlaySoundTick(3);        //播放3
                        delay(30000);

       
        }
}
录的声音地址已放置在sound.h里,程序主要参考了卖家给的程序,驱动程序读的不是很懂,但主程序很简单,请大家指教啦

messii 发表于 2011-3-14 13:36:17

isd1700.h程序如下

#define ISD1700_PU          0x01
#define ISD1700_STOP      0X02
#define ISD1700_REST      0x03
#define ISD1700_CLR_INT   0x04
#define ISD1700_RD_STAUS    0x05
#define ISD1700_RD_PLAY_PTR 0x06
#define ISD1700_PD          0x07
#define ISD1700_RD_REC_PTR0x08
#define ISD1700_DEVID       0x09

#define ISD1700_PLAY      0x40
#define ISD1700_REC         0x41
#define ISD1700_ERASE       0x42
#define ISD1700_G_ERASE   0x43
#define ISD1700_RD_APC      0x44
#define ISD1700_WR_APC1   0x45
#define ISD1700_WR_APC2   0x65

#define ISD1700_WR_NVCFG    0x46
#define ISD1700_LD_NVCFG    0x47
#define ISD1700_FWD         0x48
#define ISD1700_CHK_MEM   0x49
#define ISD1700_EXTCLK      0x4A
#define ISD1700_SET_PLAY    0x80
#define ISD1700_SET_REC   0x81
#define ISD1700_SET_ERASE   0x82
#define NULL                0x00
#define ISD_LED             0x10

messii 发表于 2011-3-14 13:36:42

sound.h程序如下

//以下为语音信息对应播放起始地址定义,A为开始,B为结束
#define sound_0A         0x0010
#define sound_0B         0x0036

#define sound_1A         0x0037
#define sound_1B         0x005A

#define sound_2A         0x005B
#define sound_2B         0x0098

#define sound_3A         0x0099
#define sound_3B         0x00D4

messii 发表于 2011-3-14 21:34:57

怎么没人理呢。。。伤心

messii 发表于 2011-3-15 23:22:50

怎么没人理啊,解释一下驱动程序也行啊

liudaolunhui 发表于 2012-10-14 21:26:44

我也不会呀!!!!!!!!!!!!!

liudaolunhui 发表于 2012-10-14 21:27:50

是编译错误码????

liudaolunhui 发表于 2012-10-14 23:09:32

楼主搞定了没有呀!!!发我一份呀!!!!!!!!

山居笔记 发表于 2012-10-18 09:51:49

楼主在吗

Foan 发表于 2012-12-11 14:04:51

什么问题?

tengever 发表于 2012-12-28 19:13:11

我也在搞这个,还用不了啊,求助啊
页: [1]
查看完整版本: 急。。。请教大虾关于ISD1760的程序问题~~不知道编的程序错在哪