目录
1.概述
1.1 简介
KT142A是一个提供串口的语音芯片,完美的集成了MP3、WAV的硬解码。内置350KByte的空间,最大支持300秒的语音长度,支持多段语音,内置空间不够也可以选择外挂spiflash存储器,同时支持直驱0.5W的扬声器,无需功放
软件支持串口通信协议,可以外挂SPIFLASH、U盘、TF卡作为存储介质,用户可以灵活的选用其中的任何一种设备作为语音的存储介质。通过简单的串口指令即可完成播放指定的语音,以及如何播放等功能,无需繁琐的底层操作,使用方便,外围简单,稳定可靠是此款产品的最大特点。
1、支持用于使用我们配套的上位机软件,直接串口下载mp3文件到芯片内置的350kByte存储空间中
2、无需任何烧录器,无需任何软件,PC虚拟外挂的SPIFLASH为存储介质的U盘功能,后面章节详细说明
3、芯片内置0.5W的功放,超宽的供电范围【3.3--5.2V】,外置2个105的电容即可正常工作,非常简单
1.2 功能简介
1、芯片支持重复烧写,支持采样率(KHz):8/11.025/12/16/22.05/24/32 |
2、24位DAC输出,动态范围支持90dB,信噪比支持85dB 。芯片支持任意切换DAC输出和PWM直驱扬声器 |
3、最大支持外挂16M字节的SPIFLASH。例如W25Q16[2M字节]、W25Q128[16M字节] |
4、USB接口更新语音文件,无需安装任何软件。支持XP和WIN7、WIN10等等系统。 |
5、支持组合播放功能,可以实现报时、报温度,在一定程度上可以替代一些昂贵的TTS方案 |
6、支持外挂多种类型的功放,如3W、5W、10W等等 。也支持内置0.5W的PWM直接驱动扬声器 |
7、支持上电循环播放的功能 |
8、可以支持多种存储介质,如:U盘、TF卡、SPIFLASH[超小型封装]作为存储介质 |
2.方案说明
芯片选用的是SOC方案,集成了一个16位的MCU,以及一个专门针对音频解码的aDSP,采用硬解码的方式,更加保证了系统的稳定性和音质。小巧的封装尺寸更加满足嵌入其它产品的需求
2.1 参数说明
名称 | 参数 |
MP3文件格式 | 1、支持所有比特率11172-3和ISO13813-3 layer3音频解码 |
2、采样率支持(KHZ):8/11.025/12/16/22.05/24/32 | |
3、支持Normal、Jazz、Classic、Pop、Rock等音效 | |
USB接口 | 2.0标准 |
UART接口 | 标准串口,TTL电平,波特率可设[指令设置] |
输入电压 | 2.7V-5.2V[7805后级串一个二极管为最佳] |
额定电流 | 10MA[静态] |
低功耗电流 | <200uA |
功放功率 | 内置0.5W的PWM输出 |
尺寸 | 参见封装章节 |
工作温度 | [-40度] -- [80度] |
湿度 | 5% ~ 95% |
主芯片型号 | KT142A[SOP16] |
2.2 管脚说明
引脚序号 | 引脚名称 | 功能描述 | 备注 |
1 | PA6 | SPI的片选 | |
2 | PA5 | SPI的数据口 | |
3 | PA4 | SPI的时钟口数字地 | |
4 | USBDM | USB接口/通用输入输出口 | 必须预留测试点 |
5 | UDBDP | USB接口/通用输入输出口 | 必须预留测试点 |
6 | PA0 | 串口-RX | 连接MCU的TX脚 |
7 | PB1 | 串口-TX | 连接MCU的RX脚 |
8 | AGND | 模拟音频地 | |
9 | PB0 | 指示灯脚 | 必须预留测试点 |
10 | VDDIO | 3.3V LDO输出[是KT142A的输出] | 必须预留测试点 |
11 | VBAT | 供电脚正极 | 4.2V为最佳 |
12 | GND | 数字地 | |
13 | SPO1 | 扬声器输出脚1 | 直驱0.5W扬声器 |
14 | SPO2 | 扬声器输出脚1 | 直驱0.5W扬声器 |
15 | PA12 | 通用输入输出口 | 有声音输出低,空闲输出高 |
16 | PA11 | 通用输入输出口 | 测试脚 |
议串口作为一种在控制领域常用的通信,我们进行了工业级别的优化,加入的帧的校验、重发、错误处理等措施,大大加强通信的稳定性和可靠性,同时可以在此基础上扩展更加强大的RS485
进行组网功能,串口的通信波特率可自行设置,默认为9600
3.1 通讯格式
支持异步串口通讯模式,通过串口接受上位机发送的命令 停止位 :1 | ||
格式:$S VER Len CMD Feedback para1 para2 checksum $O | ||
1 | 0x7E | 起始标记 |
2 | CMD | 命令字节 |
3 | lenH | 包的序号--高字节 |
4 | lenL | 包的序号--低字节 |
..... | DAT | 数据区 |
结束 | 0xEF | 结束标志 |
举个例子,如果我们指定播放SPIFLASH的分区1里面的语音播放,就需要发送:7E A5 00 02 00 01 EF 数据长度为2 ,这2个字节分别是[00 01] 。代表是指定分区1的第1段语音播放
3.2 串口下载语音的方法
3.3 参考的代码
/**
******************************************************************************
* @file main.c
* @author fire
* @version V1.0
* @date 2015-xx-xx
* @brief 串口接发测试,串口接收到数据后马上回传。
******************************************************************************
* @attention
*
* 实验平台:野火 STM32 F407 开发板
* 论坛 :http://www.firebbs.cn
* 淘宝 :https://fire-stm32.taobao.com
*
******************************************************************************
*/
#include "stm32f4xx.h"
#include "./usart/bsp_debug_usart.h"
#include "delay.h"
/**
* @brief 主函数
* @param 无
* @retval 无
*/
/**********************************************************
1、程序的整个下载流程比较复杂,不能想当然的理解,一定要配合我们给的上位机进行对比
2、下载流程,我们没有提供参考程序,需要您自己去写
3、上位机的源码我们是不提供的,您可以参考,原理其实也就是
握手---->分包发--->完毕--->退出下载---->MCU发指令点播
**********************************************************/
/**********************************************************
-- 这里是通过winhex,获取的一个小音乐文件的数组
-- 这里仅仅用来模拟测试而已
-- 很明显可以看到这个音乐文件,大概在2K
-- 这个语音文件的数组,播放的音乐是"8"
-- 详细的参见文档"20191209_如何使用WINHEX查看音频文件的数据以及生成数组"
**********************************************************/
unsigned char musicdata[2560] = {
0xFF, 0xF3, 0x28, 0xC4, 0x00, 0x09, 0xE0, 0x5D, 0x78, 0x0C, 0x18, 0xC6, 0x28, 0x0E, 0x00, 0xCA,
0x28, 0x48, 0xE3, 0x0B, 0x10, 0x2C, 0x71, 0x85, 0xA3, 0xC5, 0x62, 0x12, 0x38, 0xC3, 0x88, 0x07,
0x02, 0xDF, 0xE8, 0x32, 0xEF, 0xFF, 0xFF, 0xF4, 0x9A, 0x7F, 0xE8, 0x32, 0x09, 0x8A, 0xA1, 0xF9,
0x93, 0x26, 0x81, 0xC1, 0x65, 0x0C, 0x39, 0x25, 0x17, 0x0D, 0x80, 0xFC, 0x01, 0x13, 0xBE, 0x20,
0x71, 0x40, 0xC1, 0x22, 0xE3, 0x9D, 0xF2, 0xF9, 0xFF, 0xF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0x06, 0xD9, 0x1E,
0xBE, 0x58, 0x00, 0x44, 0x5E, 0x09, 0xB9, 0x46, 0xE3, 0xF0, 0x07, 0x99, 0x97, 0x4C, 0xCB, 0xE5,
0x96, 0x47, 0x23, 0x26, 0x50, 0xC0, 0xC1, 0x82, 0x6C, 0xFA, 0x9B, 0x8A, 0x8A, 0x8B, 0x1A, 0x02,
0x85, 0x45, 0x0F, 0xEB, 0x6F, 0xFF, 0xFD, 0x58, 0xA8, 0xA5, 0x4D, 0x16, 0x15, 0x4C, 0x41, 0x4D,
0x45, 0x33, 0x2E, 0x39, 0x38, 0x2E, 0x34, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xFF, 0xF3, 0x28, 0xC4, 0xEF, 0x0A, 0xC1, 0x4A, 0xC4, 0x7E, 0x00, 0x4C, 0xD2, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xF3, 0x28, 0xC4, 0xFF, 0x14, 0x21, 0x56,
0x58, 0x00, 0x33, 0x12, 0xE4, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0xFF, 0xF3, 0x28, 0xC4, 0xE9, 0x0B, 0x09, 0x32, 0x80, 0x56, 0x00, 0x46, 0xC0, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xF3, 0x28, 0xC4, 0xEC, 0x0A, 0x00, 0xDE,
0x44, 0x7E, 0x00, 0x46, 0xC8, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
unsigned char xxx,iii,jjj;
unsigned char KB_X;
unsigned char numnum;
unsigned char numnum_CRC;
unsigned int yyy;
unsigned char UART_DATA;
uint8_t mycode[] = {0x12,0x13,0x14};
void Key_Init()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);//使能GPIOB时钟
//GPIOB1初始化设置
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//普通输出模式
// GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOB, &GPIO_InitStructure);//初始化
}
int main(void)
{
int i,j;
delay_init(168);
/*初始化USART 配置模式为 115200 8-N-1,中断接收*/
Debug_USART_Config();
Key_Init();
/* 发送一个字符串 */
// Usart_SendString( DEBUG_USART,"这是一个串口中断接收回显实验\n");
// printf("这是一个串口中断接收回显实验\n");
while(1)
{
if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_1)==0)
{
delay_us(10000);
if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_1)==0)
{
/******************************************************
- MCU端发起下载的指令 --
******************************************************/
Usart_SendByte(USART1, 0x7E);
Usart_SendByte(USART1, 0xA0);
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, 0x03);
Usart_SendByte(USART1, 0x01); //第一个文件
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, 0x0A); //总包数---是10包
Usart_SendByte(USART1, 0xEF);
delay_us(10000); //这里延时大概在100ms
delay_us(60000);
delay_us(60000);
for(xxx = 1; xxx <= 10; xxx++)
{
Usart_SendByte(USART1, 0x7E);
Usart_SendByte(USART1, 0xA1);
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, xxx); //下载的包的序号
for(yyy=0; yyy<256; yyy++)
{
Usart_SendByte(USART1,musicdata[(xxx-1)*256 + yyy]); //当前包的实际数据
delay_us(1000);
}
Usart_SendByte(USART1, 0xEF); //结束
delay_us(1000);
}
Usart_SendByte(USART1, 0x7E);
Usart_SendByte(USART1, 0xA3);
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, 0x02);
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, 0x01);
Usart_SendByte(USART1, 0xEF); //MCU告诉KT803c 。当前的文件已经发送完毕
delay_us(10000);
Usart_SendByte(USART1, 0x7E);
Usart_SendByte(USART1, 0xA3);
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, 0x02);
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, 0xEF);//MCU告诉KT803c 。下载过程完毕,退出下载模式
delay_us(10000);
Usart_SendByte(USART1, 0x7E);
Usart_SendByte(USART1, 0xA6);
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, 0x02);
Usart_SendByte(USART1, 0x00);
Usart_SendByte(USART1, 0x01);
Usart_SendByte(USART1, 0xEF);//MCU告诉KT803c 。播放分区2里面的第1段音乐
}
}
}
}
/*********************************************END OF FILE**********************/