基于51单片机的音乐播放器

合集下载

毕业设计(论文)-基于单片机控制的音乐播放器[管理资料]

毕业设计(论文)-基于单片机控制的音乐播放器[管理资料]

单片机音乐播放器设计报告学生:XXX 指导教师:XXX内容摘要:单片机具有体积小、功能强、成本低、应用面广等优点,可以说,智能控制与自动控制的核心就是单片机。

根据要求设计一款音乐播放器,能实现音乐播放的简单功能,同时为了美化,添加了韵律闪烁彩灯,设计时采用Keil软件编程,用protues软件仿真,核心器件采用灵活性高且价格低廉的AT89C51芯片。

设计完成后系统可播放自编歌曲,同时发光二极管随着歌曲韵律闪烁。

关键词:单片机 AT89C51 音乐播放英文标题Abstract: SCM has small, strong function, low cost, application, advantages and intelligent control and automatic control of the core is the microcontroller. According to the requirements of a music player, design of music broadcast can realize simple function, and to beautify, added rhythm flashing lights, design is used when Keil C software programming, with protues software simulation, the core device adopts high flexibility and the price is cheap AT89C51 chip. The design is completed system can play Wrote songs, and leds with songs rhythm flicker.Keywords:SCM Temperature AT89C51 Music broadcast前言:微机原理和接口技术是一门实践性强的学科,不但要求有较高的理论水平,而且还要求有实际的动手能力,其中很多的原量、规则、现象等仅仅靠学习教科书是无法完全掌握的,必须通过实践才能比较直观和深刻的理解。

基于51单片机的MP3播放器设计毕业论文

基于51单片机的MP3播放器设计毕业论文

目录前言 (I)第1章绪论 (2)§1.1课题研究背景和意义 (2)§1.2研究的主要内容 (5)第2章设计方案选择 (7)§2.1设计方案 (7)§2.2选定最终设计方案 (8)第3章MP3系统硬件设计 (9)§3.1 MP3系统硬件设计的原则 (9)§3.2主控CPU的性能介绍和原理图 (10)§3.3调试接口电路 (13)§3.4 Flash存储系统 (14)§3.5电源系统部分 (15)§3.6音频和功率放大电路 (17)§3.7 MP3的原理图和PCB图 (18)第4章MP3系统软件设计 (22)第5章实验结果 (25)结论 (26)参考文献 (27)致谢 (28)附录 (29)外文资料译文 (59)摘要随着科学技术的发展,带数字语音功能的嵌入式终端类产品在日常生活中得到了广泛的使用,这也促进了与该功能相关的数字音频压缩技术的发展,在数字音频压缩技术中,MP3以其优异的性能得到了广泛的使用。

现在,具备MP3功能已成为嵌入式终端类产品的发展趋势之一。

本文介绍了一种基于51单片机的MP3播放器设计方案。

它采用ATMEL 公司专门针对MP3设计需求出品的AT89C51SND1C芯片。

文章详细论述了MP3播放器的硬件和软件结构设计流程,采用Protel99se软件画出原理图、制做印刷电路板,通过Keil编程软件对MP3软件设计中的文件解码程序、按键控制程序、USB通讯控制程序和FAT文件管理程序进行编程,通过电脑的串口和相应的软件进行调试,实现MP3实时解码过程。

实验表明,该系统工作达到了设计要求,为后续的嵌入式系统研发打下了基础,具有一定的实用价值。

关键词:单片机,MP3,AT89C51SND1C,USB,FATMP3 PLAYER DESIGN BASED ON 51 SINGLE-CHIPABSTRACTAlong with the development of science and technology, the embedded terminal products with digital audio function is widely used in our daily life, and the associated digital audio compression technologies are also highly developed, MP3 is the most popular one in various digital audio compression technologies according it’s excellent performance. Now, with MP3 function have became the trends of the embedded terminal products.This paper introduce a MP3 player design based on 51microcontroller.It uses AT89C51SND1C chip,which ATMEL company produce for MP3 design requiresments.We detailed discuss the MP3 player hardware and software design process,use Protel99se software to draw MP3 schematic, make printed circuit boards, through Keil programming software design MP3 software,such as file decoding procedures, key control procedures, USB communication and control procedures,and FAT file management procedures and programming procedures, use the computer's serial port and the corresponding software debug programs, realize real-time MP3 decoding. The experiment results show that the system meets the design requirements, creat the condition of the subsequent development of embedded systems, and has some practical value.KEY WORDS:Single chip,MP3,AT89C51SND1C,USB,FAT前言嵌入式技术作为在信息、网络与服务等支撑发展中最重要的实用技术之一,已经开始广泛应用于移动通信、消费电子、无线网络、工业控制和军事国防等社会生活的各个领域。

C51单片机的MP3播放器

C51单片机的MP3播放器

基于C51单片机的MP3播放器的硬件系统设计原理相关专题:电子应用时间:2012-04-01 09:11 来源:icbuy亿芯网便携式MP3播放器作为一种集音频播放、数据存储为一身的数码产品,其功能结构为电子设计人员所津津乐道。

MP3是MPEG一1音频III(1ayerIII)的简称。

MPEG一1音频(ISO/IECll 172―3)是目前普遍应用的音频压缩标准,其中层III的算法最为复杂,但压缩比最大,效果也最好,在低码率的条件下基本能达到CD的音质效果。

MP3标准用尽可能低的码流实现CD音质的声音而不会产生数据损失。

如果对于一段声音不进行压缩的话,那么每存储一秒钟的立体声CD音质音乐必须用1.4Mbit,这是个十分大的开销。

通过运用MPEG音频标准的压缩技术,我们可以把存储空间压缩到原来的1/12而不会降低声音的音质。

即使使用1/24的压缩因子,仍然比单纯降低采样率的音质要好。

低数据量和高播放品质的优点使其成为音乐存储、数字广播、网上音乐传输的主要方式。

人们不仅可以使用计算机软件,还可以通过数字随身听来欣赏音乐。

本设计以C51内核单片机为核心,设计了MP3播放器。

1 MP3硬件设计在该硬件系统的设计中,采用Atme 1公司生产的AT89C51SNDlC作为主控MCU。

AT89C5lSNDlC是ATMEL公司专门针对MP3的需求而设计的一款多媒体8位微处理器,使用通用的C51内核,片上集成了多种外设,为MP3产品提供了一套方便的解决方案。

该芯片对电路的高度集成大大降低了系统的耗电和发热,提高了系统的稳定性和速度,抗干扰能力也显著增强。

AT89C51SNDlC具有如下外设的集成,大大简化了电路的设计:a.MP3硬件解码器;b.可编程音频输出接口DAC;c.8位MCU C51:d.USBl.1控制器;e.内建锁相环PLL;f.多媒体卡接口适配器;g.SPI接口适配器;h.IDE/ATAPI接口;i.两路10位ADC,8kHz;j.44个通用I/0;k.两个16位定时器/计数器;1.硬件看门狗定时器;m.标准全工UART;n.两线主被动模式控制器;o.SPI主被动模式控制器;p.电源管理模块。

(精品)51单片机音乐播放器程序【整理】

(精品)51单片机音乐播放器程序【整理】

(精品)51单片机音乐播放器程序【整理】/*-----------------------------------------------名称:音乐播放日期:2009.5修改:无内容:------------------------------------------------*/#include<reg52.h> //包含头文件,一般情况不需要改动,头文件包含特殊功能寄存器的定义sbit speaker=P1^2; //定义音乐输出端口,需要连接到对应的喇叭,请参考电路图unsigned char timer0h,timer0l,time;//世上只有妈妈好数据表code unsigned char sszymmh[]={ 6,2,3, 5,2,1, 3,2,2, 5,2,2, 1,3,2, 6,2,1, 5,2,1,6,2,4, 3,2,2, 5,2,1, 6,2,1, 5,2,2, 3,2,2, 1,2,1,6,1,1, 5,2,1, 3,2,1, 2,2,4, 2,2,3, 3,2,1, 5,2,2,5,2,1, 6,2,1, 3,2,2, 2,2,2, 1,2,4, 5,2,3, 3,2,1,2,2,1, 1,2,1, 6,1,1, 1,2,1, 5,1,6, 0,0,0};// 音阶频率表高八位code unsigned char FREQH[]={0xF2,0xF3,0xF5,0xF5,0xF6,0xF7,0xF8,0xF9,0xF9,0xFA,0xFA,0xFB,0xFB,0xFC,0xFC, //1,2,3,4,5,6,7,8,i0xFC,0xFD,0xFD,0xFD,0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFF,} ;// 音阶频率表低八位code unsigned char FREQL[]={0x42,0xC1,0x17,0xB6,0xD0,0xD1,0xB6,0x21,0xE1,0x8C,0xD8,0x68,0xE9,0x5B,0x8F, //1,2,3,4,5,6,7,8,i0xEE,0x44, 0x6B,0xB4,0xF4,0x2D,0x47,0x77,0xA2,0xB6,0xDA,0xFA,0x16,};/******************************************************************/ /* 延时函数 *//******************************************************************/ void delay(unsigned char t){unsigned char t1;unsigned long t2;for(t1=0;t1<t;t1++){for(t2=0;t2<8000;t2++){;}}TR0=0;}/******************************************************************/ /* 定时器中断函数 *//******************************************************************/ void t0int() interrupt 1{TR0=0;speaker=!speaker;TH0=timer0h;TL0=timer0l;TR0=1;}/******************************************************************/ /* 音乐处理函数 *//******************************************************************/ void song(){TH0=timer0h;TL0=timer0l;TR0=1;delay(time);}/******************************************************************/ /* 主函/******************************************************************/ void main(void){unsigned char k,i;TMOD=1; //置CT0定时工作方式1EA=1;ET0=1;//IE=0x82 //CPU开中断,CT0开中断while(1){i=0;while(i<100){ //音乐数组长度,唱完从头再来k=sszymmh[i]+7*sszymmh[i+1]-1;timer0h=FREQH[k];timer0l=FREQL[k];time=sszymmh[i+2];i=i+3;song();}}}。

基于51单片机的音乐播放器设计

基于51单片机的音乐播放器设计

题目:音乐播放器课程设计(论文)任务书课程设计(论文)题目:音乐播发器基本内容:利用单片机的定时器产生各种频率的方波,信号经过放大后送到喇叭从而产生各种音调。

自行定义键盘,每按一键,可选择一首歌曲进行演奏,至少能够存储并播放十首歌曲,在LCD上显示演奏歌曲的名称并滚动显示歌词,单片机可连续播放这首歌曲,演奏可通过按键停止。

课程设计(论文)专题部分:题目:音乐播放器基本内容:通过单片机设计可以播放十首歌曲的音乐播放器,同步显示歌曲名称和歌词。

学生接受毕业设计(论文)题目日期第19 周指导教师签字:2009年7月摘要随着电子技术的发展和计算机越来越普遍的使用,单片机作为这两项技术的有机结合也得到了广泛的应用,在某些领域具有不可替代的作用。

音乐播放功能随处都会用到,如,在开发儿童智力的玩具中,等等。

目前,基于单片机实现音乐播放,其体积小、价格低、编程灵活等特点在这一领域独领风骚。

单片机的英文名称为single chip microcomputer,最早出现在20世纪70年代,国际上现在已逐渐被微控制器(Microcontroller Unit 或MCU)一词所取代。

它体积小,集成度高,运算速度快,运行可靠,功耗低,价格廉,因此在数据采集、智能化仪表、通讯设备等方面得到了广泛应用。

而8051单片机在小到中型应用场合很常见,已成为单片机领域的实际标准。

随着硬件的发展,8051单片机系列的软件工具也有了C级编译器和实时多任务操作系统RTOS,为单片机编程使用C语言提供了便利的条件;并针对单片机常用的接口芯片编制通用的驱动函数,可针对常用的功能模块,算法等编制相应的函数;C语言模块化程序结构特点,可以使程序模块大家共享,不断丰富,这样就使得单片机的的程序设计更简单可靠,实时性强,效率高。

作为测控技术与仪器的学生,掌握8051单片机硬件基础及其相关软件操作,将其应用于现代电子产品中是必要而且重要的,这次课程设计我们的题目是用单片机实验箱系统制作音乐播放器。

基于51单片机的音乐盒的设计

基于51单片机的音乐盒的设计

图2 蜂鸣器电路控制电路图4 仿真调试6.2性能分析用AT89C51单片机的I/O口产生一定频率的方波,驱动蜂鸣器,出不同的音调,从而演奏乐曲。

共有4支乐曲,每首乐曲都由相应的按键控制,并且有开关键、暂停键、上一曲以及下一曲控制键。

将源程序导入单片机后,在proteus软件中进行仿真。

我通过仿真发现,按下按8 总结通过对单片机的学习,发现对单片机的硬件设计,软件设计掌握的a您好,为你提供优秀的毕业论文参考资料,请您删除以下内容,O(∩_∩)O谢谢!!!A national survey was recently launched to evaluate the eye health of Chinese children andteenagers.On June 6, China 's annual National Day for Eye Care, the China Youth Development ServiceCenter and Zhejiang Medicine, a leading li sted Chinese pharmaceutical company, jointlyannounced the kickoff of the survey.In about one month, a questionnair e compiled by top eye care medical experts in China willbe distributed through multiple online partners, including He , as well asthrough offline survey events held in universities, middle schools and primary schools acrosst he country.A report will be released based on the survey statistics and analysis, and most importantly,guidelines for pa rents and youth on how to care for the eyes and prevent myopia — agrowing problem in China's digitized society, will also be attached on the report."Myopia is not only a disease that makes people see things blurrily, but also leads to sev erecomplications, such as glaucoma (increased pressure within the eyeball), and can causeblindness," said Zhou Yueh ua, an established eye care specialist with Beijing TongrenHospital."It is very important for parents and children to k now about the risk and care for their eyes."There are about 450 million myopia patients in China. Among Chinese my opia patients,30million are severe patients, according to ZhouThe prevalence of myopia among high school and colleg e students is more than 70 percent,and the situation is continuously worsening, he added.Sun Zhu, director with the C hina Youth Development Service Center, said long hours ofstudy, lack of exercise, especially outdoor activities, and att achment to electronic screen aresome of the top reasons behind the widespread myopia problems, and the increase ofy ounger patients, although China has made great progress in improving the hardwarefacilities and lighting conditions i n schools.He said he hopes the survey will alert people on the threatening situation, and also helpmedical experts to be tter guideline parents and children's behaviors to care for eyes, basedon the timely and factual statistics the survey col lected.A series of follow-up events will also be held in six cities, including Jinan in Shandongprovince, and Changsha i n Hunan province, to educate people on how to care for eyes afterthe survey started. More and more Chinese are jogging to get and stay fit. Most joggers will run alone, but some will jog with friends or even coaches. The Beijing Olympic Forest Park is one of the most popular spots. It is packed with runners in the afternoon, usually after work, and at weekends. Jogging after a whole day's work can be a way to unwind. It is true for He Wenjun, whose workplace is right near the forest park. She discovered her athletic aptitude at the age of seven, when she began playing tennis. Then she turned to jogging, and she has persevered with it for 10 years. "I come to jog almost every day after work, whenever I have time. I think jogging is good for my health. And for me, a girl, it helps me to achieve to eternal goal, to keep slim," He said. He says she prefers jogging alone, so she can focus better. She loves jogging, even during Beijing's smoggy days. "If the smog is severe, I'll hold off jogging for a while. But if I really want to get away from work, I'll wear a mask, or just ignore the smog and go on jogging," she said. For those who are not so athletic, jogging also has its attractions. Wu Houbin started roughly two years ago, when he was severely obese. Within two months, his weight dropped from 82 kilograms to 64 kilograms. The success helped him recover health, and he has made friends. "Jogging does not require speed, but stamina. If you want to stick to the game, you need to take it as a mission, a habit, and then eventually a hobby," Wu said. But persevering with jogging is not always easy. Jogging is beneficial for heart-lung function, and the skeletal system, but doctors say improper technique damages the joints, especially the knees and ankles. "Excessive jogging wears down the body, and harms one's health. Poor technique harms the muscles and skeleton, and can cause secondary injures. And, jogging in a bad environment can cause circulation problems," said Lu Zhiyong, attending doctor, Sports Hospital, General Admin. of Sports.Dr. Lu has some tips for joggers, and thosewho are thinking of taking it up.He says peoplesh ould first evaluate their physical condition, to decide the amount and type of exercise, and jogging in the open air is better running on a treadmill. Conrad Macaowill run special programs for the entire month of October this year to support the Hong Kong Cancer Fund's Pink Revolution, an annual campaign that seeks to raise awareness and funds for breast cancer research, the hotel recently announced. A major sponsor of the campaign for three years in a row, Conrad Macao has pledged to donate a portion of its proceeds to the fund,includ ing those collected from selling its popular bear and rubber duck merchandise, in limited pink editions. Pink is the theme for floral arrangements and decorations in the hotel in October. In addition, on Fridays that month, members of the management and staff will add something pink to their uniforms, regular e-mails and handwritten guest cards. "Breast cancer is the most prevalent type of cancer among women in Hong Kong and is also of significant concern in Macao and around the world, regardless of age," general manager Bede Barry said in a statement. The hotel has enlisted the support of a number of international and local celebrities to help drive the cause, including South Korean actor Jung Suk Won. This year, a lucky guest who stays at the hotel during the campaign and also donates money for the cause will win a necklace specially designed by Arte Madrid, a Spanish jewelry brand. Women should strive to balance quality of work and life, and have children at a young age. As a doctor I see much suffering because of this imbalance. Xiao Ying, 36, works for a large law firm. Her job means lots of travel, a heavy caseload and a large number of meetings, so her schedule is hectic. She has been pregnant twice, but had abortions on both occasions because she felt her busy,high-pressure career wasn't conducive to raising a child. She planned to have children once she had achieved career success so she could provide a stable environment for her baby. After 10 years, Xiao felt the time was right, and she tried to conceive for about six months, but was unable to become pregnant. I conducted comprehensive physicalcheckups. The results suggested that Xiao's ovarian function has declined and a bilateral oviduct blockage has occurred, meaning that in vitro fertilization is her only option. So, after reducing her workload, Xiao underwent IVF treatment. Luckily, she got pregnant after just one treatment cycle, but later experienced vaginal bleeding, and rushed to the hospital. I told her to rest and carry on with the treatment (to prevent a miscarriage). As Zubin Zarthoshtimanesh, a yoga guru, demonstrated postures at a high school stadium in Dujiangyan city, Sichuan province, some 200 students sat on colorful mats watching him closely. It was part of the first India-China international yoga festival in the provincial capital, Chengdu, in Southwest China, where more than 1,000 fans from home and abroad gathered for lessons from 20 leading practitioners of the ancient Indian regimen, from June 17-21. Yoga is to India what perhaps tai chi is to China. Many countries other than India and China, also held the first World Yoga Day on June 21, after the United Nations last year agreed to Indian Prime Minister Narendra Modi's suggestion that a special day be marked in the year for the global practice of the stress-busting regimen, which is already a multibillion dollar industry in the United States. Modi said in the speech: "Yoga is an invaluable gift of India's ancient tradition. ... It is not about exercise but to discover the sense of oneness with yourself, the world and nature."Zarthoshtimanesh, who runs his own yoga center, Iyengar Yogabhyasa, in the Indian financial capital of Mumbai, says: "Chinese students are very respectful. For me, all students are the same no matter what their race is and where they come from. The most important thing is to remove mental walls." Zarthoshtimanesh learned yoga from the late Yogacharya Iyengar and traveled with the master to different countries. Consulate General of India in southern China's Guangzhou city organized the Chengdu festival. A terrifying wooden bridge in China has just been replaced by a glass one. This, the world’s longest glass-bottomed walkway, is located in Shiniuzhai Geopark in Hunan, and spans 300m (984f) and is 180m (590f) above ground. The floor is made of double-layered glass that is24mm (0.94in), and is reportedly 25 times stronger than regular window glass. The bridge had previously been made of wood, linking the two peaks of Stone Buddha Mountain, but 11 engineers working 12 hours a day converted it to glass. Previously, you were considered brave if you steeled yourself to cross the wooden walkway; now, with its glass bo ttom, the bridge is already being referred to as “hero bridge.”The popular chain's longtime executive chef embraces mapo tofu and other exotic elements for the burger-driven menu, Liu Zhihua reports.At the age of 37, Shanghai native Lin Zhengu has become a star as a Western cuisine chef in the Chinese metropolis, a city that has a wealth of Western restaurants. The executive chef of Blue Frog Bar and Grill, a popular burger-based restaurant and bar chain on the Chinese mainland, Lin is the soul of the restaurant franchise's team of more than 550 chefs. Many of the franchise's most popular dishes are his brainchild. Lin says his secret of success is innovation rooted in experience: He spends months every year traveling and eating worldwide, seeking new ingredients and inspirations that could improve the offerings of Blue Frog restaurants. The restaurant chain regularly launches a new seasonal menu, usually featuring eight new dishes with fresh ingredients. The best-selling seasonal dishes later replace the least popular items on the regular menu, which is usually updated in late fall and boasts a selection of about 40 dishes. "Food should have no boundaries," Lin says. "As long as the food tastes good and is healthy, it doesn't really matter where it originates or how it is cooked." Lin likes to give the American-style restaurants' menu some culinary touches from other countries, such as China and Mexico, and customers love such innovation, he says. He started his career as an apprentice in a Chinese kitchen in 1993. By chance he learned from a French chef in 1994, and soon became enamored with the world of Western food. During the next couple of years, he received strict training in Western culinary art from French, Chinese and German chefs. That was rare for a Chinese chef in the 1990s, he says-and so was being a Chinese chef who spoke fluent English. When an American entrepreneur invited him to join in his startup Blue Frog in 2000, Lin didn't hesitate to resign from a five-star hotel to work in the new restaurant with just five chefs, eager to explore the excitement of a life that had yet to unfold. Since that Shanghai launch, Blue Frog has opened 24 branches in seven cities across China, including Beijing, Tianjin, Chongqing and Nanjing in Jiangsu province. The new menu for this fall, which was launched in early September, showcases how flavors of East and West meet to create a variety of delicious burgers and other entrees in the cozy, soft-lit restaurants. I liked the mapo burger best. Just imagine the flavorful combination of the hot, mildly numb-spicy mapo tofu sauce and grilled 100-percent Australian beef patty, along with a slice of cheddar cheese and a side of french fries. The savory sauce helped highlight the patty's juicy, tender texture and its delicious beef flavor. Matching that Sichuan flavor with cheese created a new taste experience.。

基于单片机的音乐播放器的设计 实验原理图

基于单片机的音乐播放器的设计 实验原理图

图2-1 C51F350单片机播放器系统结构图图2-2SPCE061A 16位单片机音乐播放器硬件结构框图2-3 C52音乐播放器组成框图图3-1 AT89C52引脚排列图图3-2 晶振电路图3-3 微分型复位电路432P1.01P1.12P1.23P1.34P1.45P1.56P1.67P1.78RST 9 3.0/RXD 10 3.1/TXD 11P3.2/INT012P3.3/INT113P3.4/T014P3.5/T115P3.6/WR 16P3.7/RD 17XTAL118XTAL219Vss 20P2.021P2.122P2.223P2.324P2.425P2.526P2.627P2.728PSEN 29ALE 30EA 31P0.732P0.633P0.534P0.435P0.336P0.237P0.138P0.039VC C 40AT89C52Y112M HZC630PF C730PFX 1X 2VC CR1VC CVC C图3-4 单片机最小系统图a) 八段共阴LED显示管原理图图b) 八段共阳LED显示管原理图图3-5 八段LED显示管原理图[7]图3-7 音乐播放器LED显示电路设计图3-8 LM2575集成稳压器的两种引脚图[11]图3-9 LM2575内部框图图3-10 电源电路的设计电路图[13]图3-11 内部结构图表3-2 音频功率放大器R1 R23.3V 1.0K 1.7K5V 1.0K 3.1K 12V 1.0K 8.84K 15V 1.0K 11.3K 输出电压可调Open 0图3-12 全数字功放与普通功放过载失真度比较图3-13 LM386引脚图图3-14 LM386方块图表3-3 LM386电子特性表图3-15 音频功率放大器[18]图4-1 主程序流程图[20]图4-2 显示子程序的流程图[21]图4-3 INT0中断模块流程[24]图4-4 T1中断模块程序流程图附录A:电气原理图321DC B AC310u FC130pC230pC5100nF+C2100uFY1D1IN5819123456781234567812345678A1LM386R1330uhR1R110KS1S2+C2330VS3OUTFbVinGNDONU2LM2575GNDP1.01P1.12P1.23P1.34P1.45P1.56P1.67P1.78RST93.0/RXD103.1/TXD11P3.2/INT012P3.3/INT113P3.4/T014P3.5/T115P3.6/WR16PSEN29XTAL118XTAL219Vss20P2.021P2.122P2.223P2.324P2.425P2.526P2.627P2.728P3.717ALE30EA31P0.732P0.633P0.534P0.435P0.336P0.237P0.138P0.039VCC40U1AT89C52VCC123。

单片机蜂鸣器音乐

单片机蜂鸣器音乐

单片机蜂鸣器音乐单片机在我们的生活中无处不在,它被广泛地应用在各种电子产品中,为我们的生活带来了便利。

今天,我要向大家介绍的是一种基于单片机的蜂鸣器音乐播放器。

一、硬件部分1、单片机:我们选用的是AT89C51单片机,它具有低功耗、高性能的特点,非常适合用于音乐播放器。

2、蜂鸣器:蜂鸣器是用来发出声音的,我们将其连接在单片机的输出口上。

3、存储芯片:为了能够播放存储在芯片中的音乐,我们需要将音乐以某种格式存储在芯片中。

常用的存储芯片有EEPROM和Flash芯片。

4、按键:为了能够选择播放不同的音乐,我们需要添加一个按键。

二、软件部分1、音乐编码:我们需要将音乐转换成二进制编码,这样才能被单片机读取并播放。

常用的音乐编码格式有MIDI、WAV等。

2、音乐播放:当按下按键时,单片机读取存储芯片中的音乐数据,并通过蜂鸣器播放。

3、音乐选择:通过按键可以选择不同的音乐进行播放。

4、音量控制:我们可以通过编程来控制蜂鸣器的音量大小。

三、调试与测试1、硬件调试:检查连接是否正确,确保没有短路或断路的情况。

2、软件调试:将程序下载到单片机中进行调试,确保能够正常播放音乐。

3、综合测试:将所有硬件和软件都连接起来进行测试,确保能够正常工作。

四、总结与展望通过本次实验,我们成功地制作了一个基于单片机的蜂鸣器音乐播放器。

它具有简单、实用的特点,可以用来播放存储在芯片中的音乐。

未来,我们可以进一步扩展其功能,例如添加更多的按键来选择不同的音乐、添加显示屏来显示歌曲名称等。

我们也可以将其应用到其他领域,例如智能家居、智能安防等。

单片机蜂鸣器唱歌程序在许多应用中,单片机蜂鸣器经常被用来发出声音或音乐。

下面是一个使用单片机蜂鸣器唱歌的程序示例。

我们需要确定单片机和蜂鸣器的连接方式。

通常,单片机具有一个内置的蜂鸣器输出引脚,可以将蜂鸣器连接到这个引脚上。

在以下的示例中,我们将假设单片机具有一个内置蜂鸣器输出引脚,并将其连接到P1.0端口上。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

基于51单片机的音乐播放器
余子健、刘胤、宋亮
摘要:本大作业是基于sst89e52rd2单片机制作的wav音乐播放器。

该播放器可以播放存在sd卡中的音乐,通过对sd卡的读取并将数字信号送入单片机中,借助8位DA转换器TLC5620 变成模拟信号,经过放大器TDA2822放大交给扬声器发出最初读取的音频信号,实现音乐播放的功能。

关键词:SD卡,WAV文件,DA,音频放大
1背景
音乐随身听产品经过几年的发展,已经变得相当成熟。

市场上可以购买到各类不同的音乐播放器,产品线涵盖了高中低不同档次。

作为学习与研究,本作品尝试利用STI51开发板板载资源以及外搭的功率放大电路制作一台音乐播放器,能够播放通过计算机拷贝在SD卡(或MMC卡、TF卡)的根目录中的某一个WAV 文件。

2硬件设计
该音乐播放器硬件组成如下
本音乐播放器使用容量为2G的SD作为外部存储器
主控制器采用SST公司生产的SST89E58RDA,其40引脚封装的芯片功能模块如图1所示。

芯片主要特想如下:
•兼容80C51系列,内置超级FLASH存储器的单片机
•工作电压VDD=4.5~5V,5V工作电压时0-40MHz频率范围
•1KB的内部RAM
•两块超级FLASH EEPROM,32KB的基本存储卡和8KB的二级存储块(扇区大小为128字节),二级存储块可用于存放掉电后要保存的数据,放在内部具有极强的抗干扰性•最大片外程序/数据地址空间为64KB
•全双工增强型UART,帧错误检测,自动地址识别
•9个中断源,4个中端优先级
•降低EMI模式(通过AUXR SFR不允许ALE输出时钟),确保了单片机的高抗干扰性•双DPTR指针(查表,寻址更方便)
图1
DA转换芯片采用TLC5620,为4路八位串行DA。

具有上电复位功能,采用单+5V电源供电,可产生一倍或二倍于基准电压与地(GND)之间的电压,且单调变化。

管脚分布如图2。

图2
功放电路采用TDA2822作为主芯片。

TDA2822 是双声道音频功率放大电路,适用于在袖珍式盒式放音机(WALKMAN)、收录机和多媒体音箱中作音频放大器。

该电路的特点如下:
电源电压范围宽(1.8~15V),电源电压可低至1.8V 仍能工作,因此,该电路适合在低电源电压下工作;
•静态电流小,交越失真也小;
•适用于单声道桥式(BTL )或立体声线路两种工作状态;
•采用双列直插8 脚塑料封装(DIP8)。

功放电路原理图如图3所示
图3
SD卡电路如图4
图4
电源供电用USB电源,LM1117-3.3V电平转换后输出的3.3V为SD卡提供电源。

3.软件设计
①SD卡
SD卡在上电初期自动进入SD总线模式,在此模式下向SD卡发送复位命令CMD0。

如果SD卡在接收复位命令过程中CS低电平有效,则进入SPI模式,否则工作在SD总线模式。

对于不带SPI串行总线接口的SST89E58RDA单片机来说,用软件来模拟SPI总线操作的具体做法是:将P0.3口(模拟CLK线)的初始状态设置为1,而在允许接收后再置P0.3为0。

这样,MCU在输出1位SCK时钟的同时,将使接口芯片串行左移,从而输出1位数据至SST89E58RDA单片机的P0.2(模拟MISO线),此后再置P0.3为1,使单片机从P0.1(模拟MOSI线)输出1位数据(先为高位)至串行接口芯片。

至此,模拟1位数据输入输出便完成。

此后再置P0.3为0,模拟下1位数据的输入输出,依此循环8次,即可完成1次通过SPI总线传输8位数据的操作。

SD卡的初始化
对SD卡进行操作首先要对SD卡进行初始化,初始化的过程中设置SD卡工作在SPI模式,其流程图如图3所示。

图5
数据块的读写
完成SD卡的初始化之后即可进行它的读写操作。

SD卡的读写操作都是通过发送SD卡命令完成的。

SPI总线模式支持单块(CMD24)和多块(CMD25)写操作,多块操作是指从指定位置开始写下去,直到SD卡收到一个停止命令CMD12才停止。

单块写操作的数据块长度只能是512字节。

单块写入时,命令为CMD24,当应答为0时说明可以写入数据,大小为512字节。

SD卡对每个发送给自己的数据块都通过一个应答命令确认,它为1个字节长,当低5位为00101时,表明数据块被正确写入SD卡。

在需要读取SD卡中数据的时候,读SD卡的命令字为CMD17,接收正确的第一个响应命令字节为0xFE,随后是512个字节的用户数据块,最后为2个字节的CRC验证码。

可见,读写SD 卡的操作都是在初始化后基于SD 卡命令和响应完成操作的,写、读SD 卡的程序流程图如图6和图7所示。

另外,利用winhex 软件,可以找到音乐文件数据在SD 卡中所处扇区号。

在读取SD 卡数据时可以直接从所需位置开始读取。

②WAV 文件
本次作用采用的音频文件为微软公司开发的WAV 音频文件,WAV 文件格式是一种由微软和IBM 联合开发的用于音频数字存储的标准,它采用RIFF 文件格式结构,非常接近于AIFF 和IFF 格式。

WAV 文件主要由WAV 文件的文件头和WAV 声音文件的数据块组成。

WAV 文件的头文件
图6 图7
WAV声音文件的数据块
利用Ultraedit软件我们可以以二进制方式查看WAV文件,将WAV文件数据区的每一个字节按照一定速率顺次送入D/A中,再经过功放电路放大,即可以实现WAV文件的播放。

WAV文件的采样率是指声音信号在“模→数”转换过程中单位时间内采样的次数。

常用的声音文件主要有两种,分别对应于单声道的11.025KHz采样率和双声道44.1KHz采样率,采样率越高的WAV音频文件音质越好。

利用Adobe公司的Audition软件可以生成任意采样率的WAV文件。

③音频信息读取和播放
本次使用的SST89E58RDA工作在11.0592MHz频率下,由于工作频率限制,WAV文件采样率不能过高,否则会由于音频信息写入DA速度不够而使声音失真。

制作时采样率使用3000Hz。

音频信息通过SPI通信从SD卡中读取,在读取到一个数据后立即写入DA。

由于定时器中断的进出会浪费较多时间,所以在程序设计时没有采用定时器中断,仅仅采用了空延迟来对写入速度进行控制。

这样做能获得比较高的写入速度,但是对写入速度的控制不够精确。

4总结
最终该播放器可以稳定播放采样率为3000Hz的WAV音频文件,声音效果一般,人声和伴奏可以分辨,带有一些杂音。

本次作业研究了音乐播放器的模型,实现了对SD卡内数据的读取与处理。

参考资料:
刘文浩,51单片机音乐播放器.pdf
TDA2822 datasheet
SanDisk datasheet
SST芯片datasheet
WAV文件播放.pdf
51单片机与SD卡的接口电路和程序.pdf 电工基地暑期电子制作教材。

相关文档
最新文档