Mini MP3 Player播放器简介与STC12例程

1、DFRobot arduino DFPlayer官方资料

1-1、简介

The DFPlayer Mini MP3 Player For Arduino is a small and low price MP3 module with an simplified output directly to the speaker. The module can be used as a stand alone module with attached battery, speaker and push buttons or used in combination with an Arduino UNO or any other with RX/TX capabilities.

简介
DFPlayer迷你MP3播放器Arduino是一个小而便宜的MP3模块,简化输出直接到扬声器。该模块可以作为独立模块使用,附带电池、扬声器和按钮,也可以与Arduino UNO或任何其他具有RX/TX功能的模块结合使用。

图1
图1-1-1:开源Mini MP3 Player播放器

2-2、 基本功能详述

  • supported sampling rates (kHz): 8/11.025/12/16/22.05/24/32/44.1/48
  • 24 -bit DAC output, support for dynamic range 90dB , SNR support 85dB
  • fully supports FAT16 , FAT32 file system, maximum support 32G of the TF card, support 32G of U disk, 64M bytes NORFLASH
  • a variety of control modes, I/O control mode, serial mode, AD button control mode
  • advertising sound waiting function, the music can be suspended. when advertising is over in the music continue to play
  • audio data sorted by folder, supports up to 100 folders, every folder can hold up to 255 songs
  • 30 level adjustable volume, 6 -level EQ adjustable

基本功能详述

  • 支持采样率(kHz): 8/11.025/12/16/22.05/24/32/44.1/48

  • 24位DAC输出,支持动态范围90dB,信噪比支持85dB

  • 完全支持FAT16、FAT32文件系统,最大支持32G的TF卡,支持32G的U盘,64M字节的NORFLASH

  • 多种控制方式,I/O控制方式,串行控制方式,AD按钮控制方式

  • 广告声音等待功能,音乐可以暂停播放。当广告结束时,音乐继续播放

  • 音频数据按文件夹排序,最多支持100个文件夹,每个文件夹最多可存放255首歌曲

  • 30级音量可调,6级EQ可调

1-3、 用途

  • Car navigation voice broadcast;
  • Road transport inspectors, toll stations voice prompts;
  • Railway station, bus safety inspection voice prompts;
  • Electricity, communications, financial business hall voice prompts;
  • Vehicle into and out of the channel verify that the voice prompts;
  • The public security border control channel voice prompts;
  • Multi-channel voice alarm or equipment operating guide voice;
  • The electric tourist car safe driving voice notices;
  • Electromechanical equipment failure alarm;
  • Fire alarm voice prompts;
  • The automatic broadcast equipment, regular broadcast.

用途

  • 汽车导航语音广播;

  • 道路运输巡视员、收费站语音提示;

  • 火车站、公交安全检查语音提示;

  • 电力、通信、金融营业厅语音提示;

  • 车辆进出通道验证,语音提示;

  • 公安边防通道语音提示;

  • 多声道语音报警或设备操作引导语音;

  • 电动旅游车安全驾驶语音提示;

  • 机电设备故障报警;

  • 火灾报警语音提示;

  • 自动播音设备,定时播音。

1-4、 引脚说明

引脚说明
请添加图片描述
图1-4-1:mini MP3 引脚说明

1-5、工作模式

1-5-1、 串口工作模式

官方的英文文档串口模式只是寥寥数笔,于是我找到mini MP3板载的芯片“YX5200-24SS串口语音芯片”的资料,对串口控制有非常详细的说明。
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
图1-5-1-2:YX5200-24SS串口语音芯片串口功能简介

1-5-2、 ADC按键工作模式

We use the AD module keys, instead of the traditional method of matrix keyboard connection, it is to take advantage of increasingly powerful MCU AD functionality, Our module default configuration 2 AD port, 20 key resistance distribution.

我们采用AD模块按键,代替传统的矩阵键盘连接方式,它是利用单片机日益强大的AD功能,我们的模块默认配置2个AD端口,20个按键电阻分布。
请添加图片描述
图1-5-2:AD 按键模式接线图

1-5-3、 普通按键工作模式

请添加图片描述
图1-5-3-1:按键控制模式接线图

2、串口模式电路搭建与例程

在这里插入图片描述
图2-1:串口模式mini MP3模块电路接线图

STC12例程

#include <STC12C5A60S2.H>
#include <intrins.h>

/*数据类型宏定义*/
#define uchar unsigned char
#define uint unsigned int

/*系统时钟空定义*/
#define MAIN_Fosc		11059200L	//宏定义主时钟HZ
//#define MAIN_Fosc		12000000L

/*全局变量定义*/
static uchar Send_buf[9] = {0};


//基于STC12单片机1ms延时函数
//函数说明:内部调用
static void Delay1ms()		
{
	# if MAIN_Fosc == 11059200L
	//晶振11.0592MHz
	unsigned char i, j;

	_nop_();
	i = 11;
	j = 190;
	do
	{
		while (--j);
	} while (--i);
	
	#elif MAIN_Fosc == 12000000L
	//晶振12.000000MHZ
	unsigned char i, j;

	_nop_();
	_nop_();
	i = 12;
	j = 168;
	do
	{
		while (--j);
	} while (--i);
	
	#endif
	
}

//基于STC12单片机ms延时函数
//函数说明:外部调用
void Delay_ms(uint time)
{
	int i;
	for(i=0; i<time; i++)
	{
		Delay1ms();
	}
}

//串口初始化,晶振11.0592,波特率9600
void UartInit(void)		//9600bps@11.0592MHz
{
	PCON &= 0x7F;		//波特率不倍速
	SCON = 0x50;		//8位数据,可变波特率
	AUXR |= 0x04;		//独立波特率发生器时钟为Fosc,即1T
	BRT = 0xDC;		//设定独立波特率发生器重装值
	AUXR |= 0x01;		//串口1选择独立波特率发生器为波特率发生器
	AUXR |= 0x10;		//启动独立波特率发生器
	
	//EA = 1;//开总中断
	//ES = 1;//开串口中断
}

/***************************************
 *函数名称:void sendArray(uchar *s, uint len)
 *函数输入:*s 发送的数组指针,len数组长度
 *函数返回:无
 *函数说明:向串口发送一段数组
 ***************************************/
void sendArray(uchar *s, uint len)
{
	uint i;
	for(i=0; i<len; i++)
	{
		SBUF = *s++;
		while(!TI);
		TI = 0;
	}
}

//向串口发送一个字符
void putchar(char ch)
{
	SBUF = ch;
	while(!TI);TI = 0;
}

/************************************************
 - 功能描述:求和校验
 - 隶属模块:
 - 参数说明:
 - 返回说明:
 - 注:      和校验的思路如下
             发送的指令,去掉起始和结束。将中间的6个字节进行累加,最后取反码
             接收端就将接收到的一帧数据,去掉起始和结束。将中间的数据累加,再加上接收到的校验
             字节。刚好为0.这样就代表接收到的数据完全正确。
**************************************************/
void DoSum( uchar *Str, uchar len)
{
    uint xorsum = 0;
    uchar i;

    for(i=0; i<len; i++)
    {
        xorsum  = xorsum + Str[i];
    }
	xorsum     = 0 -xorsum;
	*(Str+i)   = (uchar)(xorsum >>8);
	*(Str+i+1) = (uchar)(xorsum & 0x00ff);
}

/***********************************************
 - 功能描述: 串口向mini MP3发送命令[包括控制和查询]
 - 隶属模块: 外部
 - 参数说明: CMD:表示控制指令,请查阅指令表,还包括查询的相关指令
              feedback:是否需要应答[0:不需要应答,1:需要应答]
              data:传送的参数
 - 返回说明:
 - 注:       
*************************************************/
void Uart_miniMP3_SendCMD(uchar CMD, uchar feedback, uint dat)
{
	Send_buf[0] = 0xff;    							//保留字节 
	Send_buf[1] = 0x06;    							//长度
	Send_buf[2] = CMD;     							//控制指令
	Send_buf[3] = feedback;							//是否需要反馈
	Send_buf[4] = (uchar)(dat >> 8);    //datah
	Send_buf[5] = (uchar)(dat);         //datal
	DoSum(&Send_buf[0],6);              //校验
	
	putchar(0x7E);											//发送启始指令
	sendArray(&Send_buf[0], 8);					//发送此帧数据
	putchar(0xEF);											//发送结束指令
}

/*****************************************
 *函数名称:miniMP3_numBroadcasting
 *函数功能:播报组合数字
 *函数输入:num 需要播报到数字(只能播报1-9999到数字组合)
 *函数返回:无
 *****************************************/
void miniMP3_numBroadcasting(uint num)
{
	uint ge,shi,bai,qian;
	
	qian = num/1000;
	bai = num/100%10;
	shi = num/10%10;
	ge = num/1%10;
	
	if(qian != 0)
	{
		Uart_miniMP3_SendCMD(0x03, 0, qian);//播报千位数字
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, 0x0D);//播报千
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, bai);//播报百位数字
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, 0x0C);//播报百
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, shi);//播报十位数字
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, 0x0a);//播报十
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, ge);//播报个位数字
		Delay_ms(1100);
		
		return;
	}
	else if(bai != 0)
	{
		Uart_miniMP3_SendCMD(0x03, 0, bai);//播报百位数字
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, 0x0C);//播报百
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, shi);//播报十位数字
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, 0x0a);//播报十
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, ge);//播报个位数字
		Delay_ms(1100);
		
		return;
	}
	else if(shi != 0)
	{
		Uart_miniMP3_SendCMD(0x03, 0, shi);//播报十位数字
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, 0x0a);//播报十
		Delay_ms(1100);
		Uart_miniMP3_SendCMD(0x03, 0, ge);//播报个位数字
		Delay_ms(1100);
		
		return;
	}
	else if(ge != 0)
	{
		Uart_miniMP3_SendCMD(0x03, 0, ge);//播报个位数字
		Delay_ms(1100);
		
		return;
	}
}

void main(void)
{
	Delay_ms(1000);				//延时1秒等待系统稳定
	UartInit();						//串口初始化,波特率9600
	
	miniMP3_numBroadcasting(1234);
	Uart_miniMP3_SendCMD(0x03, 0, 0x11);//播放指定文件
	Delay_ms(5000);
	
	miniMP3_numBroadcasting(123);
	Uart_miniMP3_SendCMD(0x03, 0, 0x11);//播放指定文件
	Delay_ms(5000);
	
	miniMP3_numBroadcasting(12);
	Uart_miniMP3_SendCMD(0x03, 0, 0x11);//播放指定文件
	Delay_ms(5000);
	
	miniMP3_numBroadcasting(1);
	Uart_miniMP3_SendCMD(0x03, 0, 0x11);//播放指定文件
	Delay_ms(5000);
	while(1);
}

参考手册、代码例程、语音合成软件:
链接:https://pan.baidu.com/s/1hzq6GUMjYvccphqfJBP5cQ
提取码:cxv1

参考文献

[1]广州悦欣电子科技有限公司YX5200-24SS串口语音芯片简介
https://www.yxin18.com/product/product-94-261.html
[2]DFRobot arduino DFPlayer官方资料
https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299

  • 10
    点赞
  • 84
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小明n.n

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值