Playing Music With 8051 Micro Controller
Playing Music With 8051 Micro Controller
PERUMALPATTU
PERUMALPATTU
BONAFIDE CERTIFICATE
ACKNOWLEDGEMENT
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
BLOCK DIAGRAM
10
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.