FN-M16P Embedded MP3 Audio Module Datasheet
FN-M16P Embedded MP3 Audio Module Datasheet
FN-M16P Embedded MP3 Audio Module Datasheet
com
Contents
1. Overviews......................................................................................................................2
1.1. Brief Introduction...................................................................................................2
1.2. Product Features...................................................................................................2
1.3. Technical Parameters............................................................................................2
1.4. Naming Rules of Audio Files(Tracks) and Folders..................................................2
2. Pin Configuration and Summary...................................................................................3
3. Serial Communication Protocol....................................................................................4
3.1. Serial Commands Format......................................................................................4
3.2. About Checksum...................................................................................................4
3.3. Serial Commands..................................................................................................5
3.4. Examples of Sending Serial Commands................................................................6
3.5. Returned Data from Module...................................................................................8
3.6. Detailed Annotation of Serial Commands..............................................................10
3.7. Detailed Annotation of Main Query Commands.....................................................15
3.8. Examples of Serial Program.................................................................................16
4. ADkey Control.............................................................................................................18
5. Application Circuits....................................................................................................19
6. Features of GPIO.........................................................................................................22
7. PCB Size......................................................................................................................22
1
Flyron Technology Co., Ltd. www.flyrontech.com
1.Overviews
FN-M16P is a serial MP3 module that is with a perfect integrated MP3 and WMV decoder chip. It provides micro SD
card driver, and supports FAT16 and FAT32 file systems. It is able to play back specified sound files and realize
other functions through simple serial commands. In the mean time, this module supports AD key control mode that
facilitates users to develop their jobs in some simple applications. Without the cumbersome underlying operating,
easy to use, stable and reliable are the most important features of this module.
1). Audio files directly stored in the root directory of the storage device(SD card or USB flash drive) need to be
renamed as 0001.mp3/0001.wav, 0002.mp3/0002.wav, 0003.mp3/0003.wav, .......3000.mp3/3000.wav.
2
Flyron Technology Co., Ltd. www.flyrontech.com
Here it works according to physical sequence when you copy the files from computer to SD card or USB flash drive.
For example, when the module receives a command to play the track 0001.mp3, it will play the 1 st track you copied
from computer, probably 0001.mp3 or not (maybe it would play 0007.mp3 if it was the first one you copied from
computer). In order to avoid this problem, when you make the copy, rename the audio files firstly on computer and
put all the renamed files in a one folder, then press “Ctrl+A” on the key board to select all, and press “Ctrl+C” to
copy, and go back to the SD card or the USB flash drive, and press “Ctrl+V” to past all the files into the SD card or
USB flash drive. Or users just directly give up this way and just move the audio files to folders and choose to control
and play them in a folder as below.
2). Ordinary folders must be renamed as 01, 02, 03......99, and the audio files must be renamed as
001.mp3/001.wav, 002.mp3/002.wav, 003.mp3/003.wav, .......255.mp3/255.wav. It is also possible to keep the
original name when you rename a file. For example, the original name is “Yesterday Once More.mp3”, then you can
rename it as “001Yesterday Once More.mp3”.
Note: In addition, there are two special purposed folders “MP3” and “ADVERT” that can be chosen by users
to use or not according to the actual needs. Audio files stored in these two folders need to be renamed as
0001.mp3/0001.wav, 0002.mp3/0002.wav, 0003.mp3/0003.wav, .......3000.mp3/3000.wav.
1 16
VCC BUSY
2 15
RX USB-
3 14
TX USB+
4 13
DAC_R ADKEY2
5 12
DAC_L ADKEY1
6 11
SPK+ I/O2
7 10
GND GND
8 9
SPK- I/O1
3
Flyron Technology Co., Ltd. www.flyrontech.com
Serial port control mode is a common communication in the control field, based on which we conducted an
industrial level of optimization by adding frame checksum, retransmission, error handling, and other measures to
significantly strengthen the stability and reliability of communication. The default baud rate is 9600.
Supports asynchronous serial communication mode, via which accept serial commands sent by upper computer.
Communication Standard: 9600 bps
Data bits: 1
Checkout: none
Flow Control: none
Format: $S Ver. Length CMD Feedback Para_MSB Param_LSB Check_MSB Check_LSB $O
$S Start byte 0x7E
Ver. Version 0xFF by default
Length Number of byte from version info to Check_LSB, typically 0x06 (checksum not counted)
CMD Command Code
Feedback 0x01: Need feedback--send confirmation back to MCU; 0x00: No need feedback
Para_MSB Most significant byte of parameter
Para_LSB Least significant byte of parameter
Check_MSB Most significant byte of checksum
Check_LSB Least significant byte of checksum
$O End byte 0xEF
For example, if we specify playback of SD card, we need to send the command “7E FF 06 09 00 00 02 FF F0 EF”.
The number is 6 bytes, and these 6 bytes are “FF 06 09 00 00 02”. Start byte, end byte and checksum are not
counted.
Regarding to calculating checksum, you can use the following formula to count.
Checksum (2 bytes) = 0xFFFF–(Ver.+Length+CMD+Feedback+Para_MSB+Para_LSB)+1
4
Flyron Technology Co., Ltd. www.flyrontech.com
Normally it’s okay whether users choose to use checksum or not, our module can receive a serial data with or
without checksum, but some of users use a MCU without crystal oscillator, so if in that case we strongly suggest
users to add checksum to make sure the communication stability.
0x19 Set repeat playback of current track See 3.6.13 for details
0x1A Set DAC See 3.6.14 for details
3.3.2.Query Commands
5
Flyron Technology Co., Ltd. www.flyrontech.com
0x3C N/A(Reserved)
0x3D N/A(Reserved)
0x3E N/A(Reserved)
0x3F Query current online storage device See 3.7.1 for details
0x4F Query number of folders in the current storage device See 3.7.4 for details
Play Previous 7E FF 06 02 00 00 00 FE F9 EF 7E FF 06 02 00 00 00 EF
6
Flyron Technology Co., Ltd. www.flyrontech.com
Reset 7E FF 06 0C 00 00 00 FE EF EF 7E FF 06 0C 00 00 00 EF
Play 7E FF 06 0D 00 00 00 FE EE EF 7E FF 06 0D 00 00 00 EF
Pause 7E FF 06 0E 00 00 00 FE ED EF 7E FF 06 0E 00 00 00 EF
7E FF 06 1A 00 00 00 FE E1 EF 7E FF 06 1A 00 00 00 EF Turn on DAC
Set DAC
7E FF 06 1A 00 00 01 FE E0 EF 7E FF 06 1A 00 00 01 EF Turn off DAC
7
Flyron Technology Co., Ltd. www.flyrontech.com
Query current EQ 7E FF 06 44 00 00 00 FE B7 EF 7E FF 06 44 00 00 00 EF
1). After the module is powered on, normally it needs about no more than 500ms to 1500ms(depending on the
actual track quantities in the storage device) initialization time. Once the initialization is done, the module returns a
data to MCU. If it does not return a data after more than the initialization time, it means there is an error for
initialization, and please check the hardware connections.
2). The returned data from module after initialization means the current effective storage device/online equipment.
For example, the module returns 7E FF 06 3F 00 00 03 xx xx EF. 0x3F is the returned command by module, and
0x03 represents USB flash drive and SD card are effective/online at the same time. See the details as below.
SD card online 7E FF 06 3F 00 00 02 xx xx EF
PC online 7E FF 06 3F 00 00 04 xx xx EF
3). MCU can not send commands to control the module until the initialization of the module is done and a data is
returned, otherwise the commands sent by MCU will be ignored and also this will effect initializing of the module.
8
Flyron Technology Co., Ltd. www.flyrontech.com
1). There is a returned data after a track is finished playing. For example, the returned data is 7E FF 06 3C 00 00 01
xx xx EF. 0x3C represents USB flash drive and 0x3D represents SD card. 0x00 and 0x01 represents the 1 st track.
0x01 and 0xF4 represents the 500 th track(0x01F4=500).
2). Because all of the files(tracks) in the storage device are read in physical sequence, the returned data still follow
the physical sequence, which needs to be noted.
1). In order to enhance stability between data communication, the function of a feedback from module is added.
Once there is a feedback to MCU from the module, it means the module has successfully received the command
that MCU sent out. 0x41 is the returned command by module.
2). Users are free to choose this feedback or not. It’s also fine not to choose this function.
7E FF 06 40 00 00 04 xx xx EF Checksum incorrect
When the module is powered on, it reads SD card first and if SD card is not available it goes to USB flash drive.
9
Flyron Technology Co., Ltd. www.flyrontech.com
SD card is plugged in 7E FF 06 3A 00 00 02 xx xx EF
1).For example, select the first song played, and send the command 7E FF 06 03 00 00 01 FF E7 EF
7E --- Start byte
FF --- Version Information
06 --- Data length (checksum not included)
03 --- Actual command(specify playback of a track)
00 --- 0x01: need feedback; 0x00: no need feedback
00 --- Most significant byte of the track(MSB of Parameter)
01 --- Least significant byte of the track(LSB of Parameter)
FF --- Most significant byte of checksum(MSB of checksum)
E7 --- Least significant byte of checksum(LSB of checksum)
EF --- End byte
2).Regarding track selection, if choose the 100 th song(track), firstly convert 100 to hexadecimal. It is double-byte by
default, i.e. 0x0064. MSB=0x00; LSB=0x64
3).If you choose to play the 1000 th song(track), firstly convert 1000 to hexadecimal. It is double-byte, i.e. 0x03E8.
MSB=0x03; LSB=0xE8
4).And so on in the same way to the other operations, as in the embedded area hexadecimal is the most convenient
operation method.
3.6.2.Specify volume
1).Our system power-on default volume is level 30, if you want to set the volume, then directly send the
corresponding commands.
10
Flyron Technology Co., Ltd. www.flyrontech.com
2).For example, if specify the volume to level 15, send the command 7E FF 06 06 00 00 0F FF D5 EF.
3).MSB=0x00; LSB=0x0F, 15 is converted to hexadecimal 0x000F.
1).The module supports two types of playback devices(USB flash drive and SD card). The device must be on-line,
so it can be specified playback. It automatically detects if a device is on-line or not. No need users’ attention.
2).It automatically enters into the standby status after specifying a device, waiting MCU to specify a track to play. It
takes about 200ms from specifying device to the module finishes initialization of file system. Please wait for 200ms
and then send the specified command to play a track.
1).The default folders are named as "01", "11", “99” in this way. In order to be with a better system stability, it is
made to support maximum 99 folders and maximum 255 tracks in each folder..
2).For example, if specify to play “100.mp3” in the folder "01", send the command 7E FF 06 0F 00 01 64 xx xx EF
MSB: represents the name of the folder, maximum supports 99 folders from 01 - 99.
LSB: represents the track, maximum supports 255 tracks from 0x01 to 0xFF.
3).You must specify both the folder and the file name to target a track. This feature supports MP3 and WAV audio
formats.
4).The following two images illustrates the naming method of folders and files.
11
Flyron Technology Co., Ltd. www.flyrontech.com
1).We added such a control command 0x11, to meet the needs that some users need repeated playback of all
tracks in the root directory of a storage device.
2).During all repeat playback, you can still normally execute the operations Play/Pause, Previous, Next, Volume+/-,
EQ and so on.
3).After starting all repeat playback, the module will play all the tracks in the device ceaselessly again and over
again until it receives a command for stop or pause.
1).We extended such single folder function on the basis of specifying playback of folders. The folder must be
named “MP3”.
2).This special folder supports max. 65536 songs(tracks), but the operation speed will get slow along with the folder
become large, so we suggest users put no more than 3000 songs(tracks) in this folder. Audio files need to be
renamed as 0001.mp3/0001.wav, 0002.mp3/0002.wav, 0003.mp3/0003.wav, .......3000.mp3/3000.wav in this folder
as shown below.
12
Flyron Technology Co., Ltd. www.flyrontech.com
In order to meet some users’ needs that each folder is able to manage more tracks, we specially added this
command for users to use. It supports max. 15 folders only(from folder 01 to folder 15), and each folder can store
3000 tracks.
1).The command byte is 0x14.
2).For example, if we specify playback of track “1999” in the folder “12”, we need to send the serial
13
Flyron Technology Co., Ltd. www.flyrontech.com
command
7E FF 06 14 00 C7 CF FD 51 EF.
0xC7 and 0xCF are parameter, and the combined data is 0xC7CF, and totally 16 bytes.
The high 4 bytes represent the folder name; C here means the folder “12”.
The low 12 bytes represent the file name; 7CF here means the file “1999”.
3).Audio files stored in these folders need to be renamed as 0001.mp3/0001.wav, 0002.mp3/0002.wav,
0003.mp3/0003.wav, .......3000.mp3/3000.wav as shown below.
3.6.10. Stop
1).This command is used to randomly play sound files in the storage device according to physical sequence and no
matter if there is a folder or not in the device. The first sound file that is conducted to be played is the first one in the
device.
14
Flyron Technology Co., Ltd. www.flyrontech.com
Turn on DAC 7E FF 06 1A 00 00 00 FE E1 EF
When the module is working, users can use the command as above (0x3F) to query the status of the online storage
devices. For example, if the module returns the data 7E FF 06 3F 00 00 0A xx xx EF, LSB 0x0A(0000 1010)
represents SD card online. If LSB is 0x1F(0000 1111), it represents all of USB flash drive, SD card, and PC
online(PC online means module is connecting with PC via a USB cable).
1)There are 4 status(playing, paused playing, stopped playing, and in sleep) that can be queried during the module
is decoding. Users can query the current status via sending the command as above(0x42).
7E FF 06 42 00 10 00 xx xx EF Module in sleep
15
Flyron Technology Co., Ltd. www.flyrontech.com
If the folder queried is empty without any files, the module will report an error, and the data 7E FF 06 40 00 00 06
FE B5 EF will be returned.
Users can query the total folder numbers of the current storage device through sending the command above.This
just supports to query the folder numbers in the root directory of the device. Not possible to query the sub-folder
numbers(Please don’t build any sub-folders in a folder).
/******************************************************************************
- 实现功能:实现芯片上电分别指定播放第一曲和第二曲,基本的程序供用户测试
- 运行环境:STC 晶振:11.0592M 波特率:9600
- 备注 :在普中科技的 51 开发板上调试 OK --- STC89C516RD+
1、该测试程序必须是模块或者芯片方案中有设备在线,譬如 U 盘、TF 卡
******************************************************************************/
#include "REG52.h"
void Delay_Ms(INT32U z)
{
INT32U x=0 , y=0;
for(x=110 ; x>0 ;x--)
for(y=z; y>0;y-- );
}
/******************************************************************************
- 功能描述: 串口 1 初始化
- 注: 设置为 9600 波特率
16
Flyron Technology Co., Ltd. www.flyrontech.com
******************************************************************************/
void Serial_init(void)
{
TMOD = 0x20; // 设置 T1 为波特率发生器
SCON = 0x50; // 0101,0000 8 位数据位, 无奇偶校验
PCON = 0x00; //PCON=0;
TH1=256-(OSC_FREQ/COMM_BAUD_RATE/32/12);//设置为 9600 波特率
TL1=256-(OSC_FREQ/COMM_BAUD_RATE/32/12);
TR1 = 1; //定时器 1 打开
REN = 1; //串口 1 接收使能
ES = 1; //串口 1 中断使能
}
void Uart_PutByte(INT8U ch)
{
SBUF = ch;
while(!TI){;}
TI = 0;
}
/******************************************************************************
- 功能描述: 串口向外发送命令[包括控制和查询]
- 参数说明: CMD:表示控制指令,请查阅指令表,还包括查询的相关指令
feedback:是否需要应答[0:不需要应答,1:需要应答]
data:传送的参数
******************************************************************************/
void SendCmd(INT8U len)
{
INT8U i = 0 ;
Uart_PutByte(0x7E); //起始
for(i=0; i<len; i++)//数据
{
Uart_PutByte(Send_buf[i]) ;
}
Uart_PutByte(0xEF) ;//结束
}
/******************************************************************************
- 功能描述:求和校验
- 和校验的思路如下:
发送的指令,去掉起始和结束。将中间的 6 个字节进行累加,最后取反码。接收端就将接收到的一帧数据,去掉起始和结束。
将中间的数据累加,再加上接收到的校验字节。刚好为 0.这样就代表接收到的数据完全正确。
******************************************************************************/
void DoSum( INT8U *Str, INT8U len)
{
INT16U xorsum = 0;
INT8U i;
for(i=0; i<len; i++)
{
xorsum = xorsum + Str[i];
}
xorsum = 0 -xorsum;
*(Str+i) = (INT8U)(xorsum >>8);
*(Str+i+1) = (INT8U)(xorsum & 0x00ff);
}
17
Flyron Technology Co., Ltd. www.flyrontech.com
{
Send_buf[0] = 0xff; //保留字节
Send_buf[1] = 0x06; //长度
Send_buf[2] = CMD; //控制指令
Send_buf[3] = feedback;//是否需要反馈
Send_buf[4] = (INT8U)(dat >> 8);//datah
Send_buf[5] = (INT8U)(dat); //datal
DoSum(&Send_buf[0],6); //校验
SendCmd(8); //发送此帧数据
}
void main()
{
Serial_init() ;//串口寄存器的初始化设置
Uart_SendCMD(0x03 , 0 , 0x01) ;//播放第一首
Delay_Ms(1000) ;//延时大概 6S
Uart_SendCMD(0x03 , 0 , 0x02) ;//播放第二首
Delay_Ms(1000) ;//延时大概 6S
Uart_SendCMD(0x03 , 0 , 0x04) ;//播放第四首
while(1) ;
}
4. ADkey Control
K4 Play/Pause
K5 Previous Vol-
K6 Next Vol+
18
Flyron Technology Co., Ltd. www.flyrontech.com
5. Application Circuits
19
Flyron Technology Co., Ltd. www.flyrontech.com
Note: When using a 5V MCU, please attach a 1K resistor between the TX and RX ports.
Note: Between headphone and module, a 100R resistor can be added to make the limiting.
20
Flyron Technology Co., Ltd. www.flyrontech.com
21
Flyron Technology Co., Ltd. www.flyrontech.com
6. Features of GPIO
22