0% found this document useful (0 votes)
605 views16 pages

Playing Music With 8051 Micro Controller

This document describes a student project to play music using an 8051 microcontroller and LM386 audio amplifier. It includes the circuit diagram, source code, and details about connecting the microcontroller, amplifier, and other components. The source code uses a lookup table to send digital signals from the microcontroller to the amplifier to generate the notes of a simple song. The project aims to demonstrate an application of microcontrollers for playing music.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
605 views16 pages

Playing Music With 8051 Micro Controller

This document describes a student project to play music using an 8051 microcontroller and LM386 audio amplifier. It includes the circuit diagram, source code, and details about connecting the microcontroller, amplifier, and other components. The source code uses a lookup table to send digital signals from the microcontroller to the amplifier to generate the notes of a simple song. The project aims to demonstrate an application of microcontrollers for playing music.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

1

SRIRAM ENGINEERING COLLEGE

PERUMALPATTU

PLAYING MUSIC WITH

8051 MICRO CONTROLLER

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING
MINI PROJECT IN MICROCONTROLLER
2010-2011
N.M.PREM CHAND 11509104034
R.DINESH 11509104008
T.GANESH 11509104011
V.JOSHUA VICTOR 11509104018

GUIDED BY:MS.G.RAMYA B.E…,


2

SRIRAM ENGINEERING COLLEGE

PERUMALPATTU

BONAFIDE CERTIFICATE

This is to certify that this is a bonafide certificate record of


work done by following students of second year, computer
science and engineering department during the year 2010-2011
N.M.PREM CHAND 11509104034
R.DINESH 11509104008
T.GANESH 11509104011
V.JOSHUA VICTOR 11509104018

SIGNATURE OF GUIDE SIGNATURE OF HOD


3

ACKNOWLEDGEMENT

We wish to express our sincere thanks to our respected Head of


Department of Computer Science Engineering Mrs.S.V.PRIYA M.E.,
(PhD) and to our respected Dean of Department of Computer Science
Engineering Mrs.E.A.MARY ANITA M.E.,(PhD)., for having helped us
to finish our project work “PLAYING MUSIC WITH
MICROCONTROLLER” successfully by giving as the necessary advices
and required financial help.

We would like to convey our deep sense of gratitude to our guide


MS.G.RAMYA B.E., LECT/CSE for this mindful guidance and worthy
and timely advice for the development completion of the project.

We also extend our hearty thanks to all staff members and lab
technicians of computer science department, who helped as directly or
indirectly for the successful completion of our project work.

We are very much grateful to our beloved parents for their moral
supports to do this project.

CONTENTS:
4

 ABSTRACT

 INTRODUCTION

 PIN CONFIGURATION

 PIN DETAILS

 BLOCK DIAGRAM

 CIRCUIT DIAGRAM

 SOURCE CODE

 CONCLUSION

 BIBLIOGRAPHY
5

ABSTRACT
This report describes our group's implementation of an application of
8051 microcontroller in playing music using IC-LM386 as an audio
amplifier and 8952 microcontroller.
The circuit diagram represents the connections which should be given
to implement a music player using the IC-LM386 audio amplifier,
8051 microcontroller and 8952 micro controller.
The object code which instructs the microcontroller to command the
IC-LM386 audio amplifier to convert the digital signals into audio
signals.
6

INTRODUCTION
Microcontrollers as the name suggests, are small controllers. They are
like single chip computers that often embedded into other systems to
function as processing/controlling unit.
A microcontroller has a CPU in addition to a fixed amount of RAM,
ROM and I/O parts and a timer on a single chip. Fixed amount of on-
chip RAM, ROM, timer and I/O parts in microcontrollers makes them
ideal for many applications in which cost and space are less.
The word microprocessor means a CPU only. The functional blocks
like memory and other peripherals are to be connected externally to a
microprocessor chip to make a complete microcomputer. But the
microcontrollers are having all these facilities in a single chip.
The microcontrollers are used for many applications. In this project
work the 8051 microcontroller is used to play music with the help of
8952 and IC-LM386 (audio amplifier).

PIN CONFIGURATION
7

8051 MICROCONTROLLER
8

PIN DETAILS

Pins 1-8: Port 1 Each of these pins can be configured as an input or


an output.
Pin 9: RS A logic one on this pin disables the microcontroller and
clears the contents of most registers. In other words, the positive
voltage on this pin resets the microcontroller. By applying logic zero
to this pin, the program starts execution from the beginning.
Pins10-17: Port 3 Similar to port 1, each of these pins can serve as
general input or output. Besides, all of them have alternative
functions:
Pin 10: RXD Serial asynchronous communication input or Serial
synchronous communication output.
Pin 11: TXD Serial asynchronous communication output or Serial
synchronous communication clock output.
Pin 12: INT0 Interrupt 0 input.
Pin 13: INT1 Interrupt 1 input.
Pin 14: T0 Counter 0 clock input.
Pin 15: T1 Counter 1 clock input.
Pin 16: WR Write to external (additional) RAM.
Pin 17: RD Read from external RAM.
Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz
crystal which specifies operating frequency is usually connected to
these pins. Instead of it, miniature ceramics resonators can also be
used for frequency stability. Later versions of microcontrollers
operate at a frequency of 0 Hz up to over 50 Hz.
Pin 20: GND Ground.
Pin 21-28: Port 2 If there is no intention to use external memory then
these port pins are configured as general inputs/outputs. In case
external memory is used, the higher address byte, i.e. addresses A8-
A15 will appear on this port. Even though memory with capacity
of 64Kb is not used, which means that not all eight port bits are used
for its addressing, the rest of them are not available as
inputs/outputs.
Pin 29: PSEN If external ROM is used for storing program then a
logic zero (0) appears on it every time the microcontroller reads a
byte from memory.
9

Pin 30: ALE Prior to reading from external memory, the


microcontroller puts the lower address byte (A0-A7) on P0 and
activates the
ALE output. After receiving signal from the ALE pin, the external
register (usually 74HCT373 or 74HCT375 add-on chip) memorizes
the state of P0 and uses it as a memory chip address. Immediately
after that, the ALU pin is returned its previous logic state and P0 is
now used as a Data Bus. As seen, port data multiplexing is performed
by means of only one additional (and cheap) integrated circuit.
In other words, this port is used for both data and address
transmission.
Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for
data and address transmission with no regard to whether there is
internal memory or not. It means that even there is a program written
to the microcontroller, it will not be executed. Instead, the
program written to external ROM will be executed. By applying logic
one to the EA pin, the microcontroller will use both memories,
first internal then external (if exists).
Pin 32-39: Port 0 Similar to P2, if external memory is not used, these
pins can be used as general inputs/outputs. Otherwise, P0 is
configured as address output (A0-A7) when the ALE pin is driven
high (1) or as data output (Data Bus) when the ALE pin is driven
low (0).
Pin 40: VCC +5V power supply.

BLOCK DIAGRAM
10

8051 MICRO CONTROLLER

CIRCUIT DIAGRAM
11
12

SOURCE CODE:
[code:asm]ORG 0000H
LJMP START
ORG 000BH
INC 20H; interruption of Counter 1
MOV TH0, #0D8H
MOV TL0, #0EFH; 12M crystal to create a 10 ms interruption
RETI
START:
MOV SP, #50H
MOV TH0, #0D8H
MOV TL0, #0EFH
MOV TMOD, #01H
MOV IE, #82H
MUSIC0:
NOP
MOV DPTR, #DAT; first address of the table to send DPTR
MOV 20H, #00H; interrupt counter
MOV B, #00H; table number
MUSIC1:
NOP
CLR A
MOVC A, @A+DPTR; access code from look-up table
JZ END0; is 00H, then the end of music
CJNE A,#0FFH, MUSIC5
LJMP MUSIC3
MUSIC5:
NOP
MOV R6, A
INC DPTR
MOV A, B
MOVC A,@A+DPTR; access beat code and send to R7
MOV R7, A
SETB TR0; start counting
MUSIC2:
NOP
CPL P3.0
13

MOV A, R6
MOV R3, A
LCALL DEL
MOV A, R7
CJNE A,20H,MUSIC2; interrupt counter (20H) = R7
; Range, then continue to cycle
MOV 20H,#00H
INC DPTR
; INC B
LJMP MUSIC1
MUSIC3:
NOP
CLR TR0; ending of 100 ms
MOV R2,#0DH
MUSIC4:
NOP
MOV R3,#0FFH
LCALL DEL
DJNZ R2, MUSIC4
INC DPTR
LJMP MUSIC1
END0:
NOP
MOV R2,#64H; song ended after 1 seconds delay
MUSIC6:
MOV R3,#00H
LCALL DEL
DJNZ R2, MUSIC6
LJMP MUSIC0
DEL:
NOP
DEL3:
MOV R4,#02H
DEL4:
NOP
DJNZ R4,DEL4
NOP
14

DJNZ R3,DEL3
RET
NOP
DAT:
db 26h, 20h, 20h, 20h, 20h, 20h, 26h, 10h, 20h, 10h, 20h, 80h, 26h,
20h, 30h, 20h
db 30h, 20h, 39h, 10h, 30h, 10h, 30h, 80h, 26h, 20h, 20h, 20h, 20h,
20h, 1ch, 20h
db 20h, 80h, 2bh, 20h, 26h, 20h, 20h, 20h, 2bh, 10h, 26h, 10h, 2bh,
80h, 26h, 20h
db 30h, 20h, 30h, 20h, 39h, 10h, 26h, 10h, 26h, 60h, 40h, 10h, 39h,
10h, 26h, 20h
db 30h, 20h, 30h, 20h, 39h, 10h, 26h, 10h, 26h, 80h, 26h, 20h, 2bh,
10h, 2bh, 10h
db 2bh, 20h, 30h, 10h, 39h, 10h, 26h, 10h, 2bh, 10h, 2bh, 20h, 2bh,
40h, 40h, 20h
db 20h, 10h, 20h, 10h, 2bh, 10h, 26h, 30h, 30h, 80h, 18h, 20h, 18h,
20h, 26h, 20h
db 20h, 20h, 20h, 40h, 26h, 20h, 2bh, 20h, 30h, 20h, 30h, 20h, 1ch,
20h, 20h, 20h
db 20h, 80h, 1ch, 20h, 1ch, 20h, 1ch, 20h, 30h, 20h, 30h, 60h, 39h,
10h, 30h, 10h
db 20h, 20h, 2bh, 10h, 26h, 10h, 2bh, 10h, 26h, 10h, 26h, 10h, 2bh,
10h, 2bh, 80h
db 18h, 20h, 18h, 20h, 26h, 20h, 20h, 20h, 20h, 60h, 26h, 10h, 2bh,
20h, 30h, 20h
db 30h, 20h, 1ch, 20h, 20h, 20h, 20h, 80h, 26h, 20h, 30h, 10h, 30h,
10h, 30h, 20h
db 39h, 20h, 26h, 10h, 2bh, 10h, 2bh, 20h, 2bh, 40h, 40h, 10h, 40h,
10h, 20h, 10h
db 20h, 10h, 2bh, 10h, 26h, 30h, 30h, 80h, 00H
END[/code]
15

CONCLUTION
This project concludes that a small application like playing
music is built with 8051 microcontroller and a simple IC-LM386
audio amplifier. Even small applications can be built with 8051
microcontrollers.
16

BIBLIOGRAPHY

 Ramesh Gaonkar-“MicroprocessorArchitecture
Programming and Applicationwith 8085”-
PenramPublications pvt Ltd-5 E/Pearson 2000.

 P.S.Manoharan-“Microprocessors and microcontrollers”


- charulatha publications nov 2009.

You might also like