问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

基于52单片机ISD1760语音芯片的原理图和程序代码。

发布网友 发布时间:2022-05-09 00:11

我来回答

1个回答

热心网友 时间:2024-01-27 18:38

#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
//******************定义端口******************//
sbit SS = P1^0;
sbit SCK = P1^1;
sbit MOSI = P1^2;
sbit MISO = P1^3;
sbit PR = P1^4;//PLAY = 0;REC = 1;
sbit STOP = P1^5;
sbit AN = P1^6;
sbit LED = P1^7;
//******************定义ISD1700状态寄存器及各标志位******************//
uchar bdata SR0_L;//SR0寄存器低位、高位
uchar bdata SR0_H;
uchar bdata SR1;//SR1寄存器
uchar APC_L = 0, APC_H = 0;//APC寄存器
uchar PLAYADDL = 0, PLAYADDH = 0;//放音指针低位、高位
uchar RECADDL = 0, RECADDH = 0;//录音指针低位、高位

sbit CMD_ERR = SR0_L^0;//SPI指令无效标志位
sbit FULL = SR0_L^1;//芯片存储空间满标志位
sbit PU = SR0_L^2;//上电标志位
sbit EOM = SR0_L^3;//EOM标志位
sbit INT = SR0_L^4;//操作完成标志位
sbit RDY = SR1^0;//芯片空闲标志位
sbit ERASE = SR1^1;//擦除标志位
sbit PLAY = SR1^2;//放音标志位
sbit REC = SR1^3;//录音标志位
//******************定义标志位******************//
uchar bdata fang;
sbit PR_fang = fang^1;//录音、放音标志位,放音=0,录音=1
sbit Erase_fang = fang^4;//擦出标志位
sbit STOP_fang = fang^7;//停止放音标志位
//******************延时μs******************//
void delay(uint time)//延时n微秒
{
while(time!=0)
{
time--;
}
}
//******************延时ms******************//
void delayms(uint time)//延时n毫秒
{
for(time; time>0; time--)
{
TH0 = 0xfc;
TL0 = 0x18;
TR0 = 1;//计数器0启动
while(TF0!=1);//计数溢出处理
TF0 = 0;
TR0 = 0;
}
}
//******************CPU初始化******************//
void cpu_init (void)
{
P1 = 0xFF;
P2 = 0xFF;
P3 = 0xFF;
TMOD = 0x01;//定时器初始化,工作于方式1
EA = 0;//关中断
fang = 0;//标志位归0
LED = 1;//关指示灯
}
//******************发送、读回数据******************//
uchar isd_senddata (uchar dat)
{
uchar i, BUF_ISD = dat;
SS = 0;
SCK = 1;
delay(4);
for(i=0; i<8; i++)
{
SCK = 0;
if((BUF_ISD&0x01)==1)
{
MOSI = 1;
}
else
{
MOSI = 0;
}
BUF_ISD = BUF_ISD >> 1;
if(MISO)
{
BUF_ISD = BUF_ISD|0x80;
}
SCK = 1;
delay(6);
}
MOSI = 0;
return(BUF_ISD);
}
//******************上电******************//
void isd_pu (void)
{
isd_senddata (0x01);
isd_senddata (0x00);
SS = 1;
delayms(50);
}
//******************停止当前操作******************//
void isd_stop (void)
{
isd_senddata (0x02);
isd_senddata (0x00);
SS = 1;
delayms(50);
}
//******************复位******************//
void isd_reset (void)
{
isd_senddata (0x03);
isd_senddata (0x00);
SS = 1;
}
//******************清除中断******************//
void isd_clr_int (void)
{
isd_senddata (0x04);
isd_senddata (0x00);
SS = 1;
}
//******************读状态寄存器内容******************//
void isd_rd_status (void)
{
isd_senddata (0x05);
isd_senddata (0x00);
isd_senddata (0x00);
SS = 1;
delay(2);
SR0_L = isd_senddata (0x05);
SR0_H = isd_senddata (0x00);
SR1 = isd_senddata (0x00);
SS = 1;
}
//******************读放音指针******************//
void isd_rd_playptr (void)
{
isd_senddata (0x06);
isd_senddata (0x00);
isd_senddata (0x00);
isd_senddata (0x00);
SS = 1;
delay(2);
SR0_L = isd_senddata (0x06);
SR0_H = isd_senddata (0x00);
PLAYADDL = isd_senddata (0x00);
PLAYADDH = isd_senddata (0x00);
SS = 1;
}
//******************下电******************//
void isd_pd (void)
{
isd_senddata (0x07);
isd_senddata (0x00);
SS = 1;
delayms(50);
}
//******************读录音指针******************//
void isd_rd_recptr (void)
{
isd_senddata (0x08);
isd_senddata (0x00);
isd_senddata (0x00);
isd_senddata (0x00);
SS = 1;
delay(2);
SR0_L = isd_senddata (0x08);
SR0_H = isd_senddata (0x00);
RECADDL = isd_senddata (0x00);
RECADDH = isd_senddata (0x00);
SS = 1;
}
//******************读芯片ID******************//
uchar isd_devid (uchar deviceNO)
{
isd_senddata (0x09);
isd_senddata (0x00);
isd_senddata (0x00);
SS = 1;
delay(2);
isd_senddata (0x09);
isd_senddata (0x00);
deviceNO = isd_senddata (0x00);
SS = 1;
return(deviceNO);
}
//******************放音******************//
void isd_play (void)
{
isd_senddata (0x40);
isd_senddata (0x00);
SS = 1;
}
//******************录音******************//
void isd_rec (void)
{
isd_senddata (0x41);
isd_senddata (0x00);
SS = 1;
}
//******************擦除******************//
void isd_erase (void)
{
isd_senddata (0x42);
isd_senddata (0x00);
SS = 1;
}
//******************全部擦出******************//
void isd_g_erase (void)
{
isd_senddata (0x43);
isd_senddata (0x00);
SS = 1;
}
//******************读APC寄存器内容******************//
void isd_rd_apc (void)
{
isd_senddata (0x44);
isd_senddata (0x00);
isd_senddata (0x00);
isd_senddata (0x00);
SS = 1;
delay(2);
SR0_L = isd_senddata (0x44);
SR0_H = isd_senddata (0x00);
APC_L = isd_senddata (0x00);
APC_H = isd_senddata (0x00);
SS = 1;
}
//******************写APC寄存器******************//
void isd_wr_apc2 (uchar apcdatl,apcdath)
{
isd_senddata (0x65);
isd_senddata (apcdatl);
isd_senddata (apcdath);
SS = 1;
}
//******************将APC寄存器内容写入NVCFG******************//
void isd_wr_nvcfg (uchar apcdatl,apcdath)
{
isd_senddata (0x46);
isd_senddata (apcdatl);
isd_senddata (apcdath);
SS = 1;
}
//******************将NVCFG内容写入APC******************//
void isd_ld_nvcfg (void)
{
isd_senddata (0x47);
isd_senddata (0x00);
SS = 1;
}
//******************快进******************//
void isd_fwd (void)
{
isd_senddata (0x48);
isd_senddata (0x00);
SS = 1;
}
//******************空检查******************//
void isd_chk_mem (void)
{
isd_senddata (0x49);
isd_senddata (0x00);
SS = 1;
}
//******************外部时钟的启用、关闭******************//
void isd_extclk (void)
{
isd_senddata (0x4a);
isd_senddata (0x00);
SS = 1;
}
//******************指定地址放音******************//
void isd_set_play (uchar saddl,saddh,eaddl,eaddh)
{
isd_senddata (0x80);
isd_senddata (0x00);
isd_senddata (saddl);
isd_senddata (saddh);
isd_senddata (eaddl);
isd_senddata (eaddh);
isd_senddata (0x00);
SS = 1;
}
//******************指定地址录音******************//
void isd_set_rec (uchar saddl,saddh,eaddl,eaddh)
{
isd_senddata (0x81);
isd_senddata (0x00);
isd_senddata (saddl);
isd_senddata (saddh);
isd_senddata (eaddl);
isd_senddata (eaddh);
isd_senddata (0x00);
SS = 1;
}
//******************指定地址擦除******************//
void isd_set_erase (uchar saddl,saddh,eaddl,eaddh)
{
isd_senddata (0x82);
isd_senddata (0x00);
isd_senddata (saddl);
isd_senddata (saddh);
isd_senddata (eaddl);
isd_senddata (eaddh);
isd_senddata (0x00);
SS = 1;
}
//******************芯片系统初始化******************//
void isd_init (void)
{
uchar i = 2;
SS = 1;
SCK = 1;
MOSI = 0;
do
{
isd_pu ();
isd_rd_status ();
}while(CMD_ERR||(!PU));
isd_wr_apc2 (0x40,0x04);
do
{
isd_rd_status ();
}while(RDY==0);
do
{
LED = 0;
delayms(300);
LED = 1;
delayms(300);
i--;
}while(i>0);
}
//******************isd1700的相关操作******************//
void isdwork (void)
{
uchar i;
switch (fang)
{
case 0x00:
{
do
{
isd_rd_status ();
}while(RDY==0);
delayms(10);
isd_play ();
delayms(2);
LED = 0;
do
{
isd_rd_status ();
if(STOP==0)
{
delayms (10);
if(STOP==0)
{
LED = 1;
isd_clr_int ();
isd_stop ();
isd_reset ();
isd_pd ();
isd_init ();
return;
}
}
}while(PLAY==1);
LED = 1;
isd_clr_int ();
do
{
isd_rd_status ();
}while(RDY==0);
delayms (10);
isd_fwd ();
do
{
isd_rd_status ();
}while(RDY==0);
}
break;
case 0x02:
{
isd_clr_int ();
do
{
isd_rd_status ();
}while(RDY==0);
delayms(10);
isd_rec ();
delayms(2);
LED = 0;
do
{
isd_rd_status ();
if(FULL==1)
{
for(i=3; i>0; i--)
{
LED = 0;
delayms (300);
LED = 1;
delayms (200);
}
}
}while(AN==0);
isd_clr_int ();
isd_stop ();
LED = 1;
}
break;
case 0x10:
{
do
{
isd_rd_status ();
}while(RDY==0);
delayms (10);
isd_g_erase ();
delayms (2);
do
{
isd_rd_status ();
}while(RDY==0);
for(i=3; i>0; i--)
{
LED = 0;
delayms (300);
LED = 1;
delayms (200);
}
}
break;
case 0x80:
{
isd_clr_int ();
isd_stop ();
isd_reset ();
isd_pd ();
}
break;
}
}
//******************主程序******************//
void main (void)
{
uchar i;
cpu_init ();
delayms (1);
isd_init ();
while(1)
{
if(AN==0)
{
delayms (10);
if(AN==0)
{
if(PR==1)
{
PR_fang = 1;
}
else
{
PR_fang = 0;
}
isdwork ();
}
}
if(STOP==0)
{
delayms (10);
if(STOP==0)
{
for(i=100; i>0; i--)
{
if(STOP==1)
{
STOP_fang = 1;
isdwork ();
isd_init ();
break;
}
delayms(30);
}
if (STOP_fang==1)
{
fang = 0;
continue;
}
Erase_fang = 1;
isdwork ();
}
}
}
}
这个是按键录放的例程,你可以根据这个例程自己修改一下追问算了,本来也不报太大期望,你的这个我已经有在网上找到了;硬件原理图设计我就参考isd1760基本中文资料就好了!

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
为什么来大姨妈胸会胀 少儿学什么舞蹈 青年学什么舞蹈好 成年人学什么舞蹈 福州企业最低工资标准 2013年厦门的底薪是多少 生产要素的需求有哪些性质 生产要素的需求有何特点? 什么是生产要素需求 微观经济学要素需求什么是条件要素需求?它和要素需求有什么不同?_百度... 想做一个能录音座机电话的电路板。芯片为TC8831F,求电路图和原理 基于tr16f064b的录音器电路图 求一录音芯片ISD1760录音放音电路图 手机机身的内存和插内存卡的,用起来有什么不一样的? 友林存储卡用在行车记录仪上怎么样? BL KE内存卡怎么样? 购买电冰箱时应进行哪些检查 304不锈钢材质的保温杯能放饮料吗 企业55岁退休政策 - 信息提示 那里有比较厉害的风水师? 中国的那几个省的风水先生或者八字先生最厉害,技术最高? 北京哪里有会钱式鬼门十三针疗法的本人失眠有十几年了,吃了很多药,也无济于事,听说钱式鬼门十三针疗 本人祖传鬼门十三针 截根疗法现在寻找传人招收学员? 苹果是别人的,现在用自己的手机号重新登陆,怎样删除以前的和数据? 苹果手机如何清除多个 was were的用法 抖音评论情节严重会怎么样 如何清除在电脑桌面右边弹出的游戏广告?? 用英语介绍植树节 MP3怎样构成的啊!硬件! tda2030和51单片机做音频功率放大器求设计思路 框图及原理图 为什么FM1188低功耗音频芯片调试有杂音问题 tda2030音频放大电路 lm3914音频闪灯电路图 关于幅频特性校正电路!100高分,在线等,急!! 电路图中的黑色小三角表示什么 小米9se电信卡插卡1还是卡2信号好 捣了蟑螂窝之后还会不会回来 新西兰antipodes怎么样 antipodes哪个东西好用 antipodes 这个牌子好用吗?知道的姐妹来说一下。 敏感肌推荐用什么护肤品? 这是什么鸟,下面有图 手机的系统指令都有什么啊?如“*#06#”是手机串号。。我是nokia5250 win10系统怎样系统设置默认浏览器 求一张PS作业的海报(像素300) 有素材文件和成品图 求PS海报成品 PSD个格式文件加素材 5个图层以上 急用 7 6 7 7 9 7 8 5 8 谁能提供雪花啤酒的广告视频下载(用作素材,要求高清) ps 旅游节海报素材