Upload
vinisha-sabharwal
View
1.440
Download
0
Embed Size (px)
DESCRIPTION
The minor project on a Dgital Dice that also displays on its LCD with full description and program.
Citation preview
DIGITAL DICE
USING
8051MICROCONTROLLERS
….. Man’s glory lies in his knowledge,
his upright conduct, his praise-worthy character,
his wisdom, and not in his nationality or rank
--Baha’ullah
(From, the book The 8051 Microcontroller and Embedded systems- Mazidi )
An EMBEDDED SYSTEM
• Means a processor is embedded in that application
• Only one application software typically burnt into the ROM
• Only one task can be performed using the micro controller/processor
• E.g. Video game player, printer, keyboard etc.
04/11/2023 CDAC,Mohali 4
Features of Different processor Architectures…
CISC
•Addressing modes.
•Variable length inst.
•No. of clocks >1
•Less general purpose internal registers
•x86,8051…
RISC
•Load/store Architecture generally.
•Fixed length instruction
•Generally inst.=1 clock
•More general purpose internal registers
•PIC,ARM,AVR…
04/11/2023 CDAC,Mohali 5
Address space architecture• Memory is needed for programs and data.• Program memory used in embedded systems is typically of
non-volatile type.• Data memory used is SRAM- or DRAM- type volatile
memory.
Von Neumann-architecture: Program and data located in same address space.
Harvard-architecture: Separate address spaces and buses for program and data memories.
Harvard Vs Von Neumann…
Need to learn Microprocessors/controllers
• The microprocessor is the core of computer systems.• Nowadays many communication, digital entertainment,
portable devices, are controlled by them.
• A designer should know what types of components he needs, ways to reduce production costs and product reliable.
• Reduce chip count.
• Many applications do not require as much computing power.
• Reduced power consumption.
• Reduced design cost
Necessary tools for a microprocessor/controller
• CPU: Central Processing Unit• I/O: Input /Output• Bus: Address bus & Data bus• Memory: RAM & ROM• Timer• Interrupt• Serial Port• Parallel Port
Microprocessor vs. Microcontroller
Microprocessor • CPU is stand-alone,
RAM, ROM, I/O, timer are separate
• designer can decide on the amount of ROM, RAM and I/O ports.
• expansive• versatility • general-purpose
Microcontroller• CPU, RAM, ROM, I/O
and timer are all on a single chip
• fix amount of on-chip ROM, RAM, I/O ports
• for applications in which cost, power and space are critical
• single-purpose
04/11/2023 CDAC,Mohali 10
•Useful for small computing tasks
•Adequate for many control and monitoring applications
•Used in communications as serial ASCII data is also stored in byte size.
•Most integrated circuit memories arranged in an 8-bit configuration
Eight - Bit Microcontrollers
Block Diagram Of 8051
CPU
On-chip RAM
On-chip ROM for program code
4 I/O Ports
Timer 0
Serial PortOSC
Interrupt Control
External interrupts
Timer 1
Timer/Counter
Bus Control
TxD RxDP0 P1 P2 P3
Address/Data
Counter Inputs
Pin Description of the 8051
1234567891011121314151617181920
4039383736353433323130292827262524232221
P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7RST
(RXD)P3.0(TXD)P3.1
(T0)P3.4(T1)P3.5
XTAL2XTAL1
GND
(INT0)P3.2(INT1)P3.3
(RD)P3.7(WR)P3.6
VccP0.0(AD0)P0.1(AD1)P0.2(AD2)P0.3(AD3)P0.4(AD4)P0.5(AD5)P0.6(AD6)P0.7(AD7)EA/VPPALE/PROGPSENP2.7(A15)P2.6(A14)P2.5(A13)P2.4(A12)P2.3(A11)P2.2(A10)P2.1(A9)P2.0(A8)
8051
Types of Microcontrollers
04/11/2023 CDAC,Mohali 14
Logic Symbols…
RESET Value of Some 8051 Registers:
0000DPTR
0007SP
0000PSW
0000B
0000ACC
0000PC
Reset ValueRegister
RAM are all zero.
Stack in the 8051
• The register used to access the stack is called SP (stack pointer) register.
• The stack pointer in the 8051 is only 8 bits wide, which means that it can take value 00 to FFH. When 8051 powered up, the SP register contains value 07.
7FH
30H
2FH
20H
1FH
17H10H
0FH
07H
08H
18H
00HRegister Bank 0
)Stack (Register Bank 1
Register Bank 2
Register Bank 3
Bit-Addressable RAM
General User RAM & Stack space
Internal RAM
04/11/2023 CDAC,Mohali 17
Alternate uses of Port- 3 pinsPINS ALTERNATE USE SFR
P3.0 RXD Serial data input SBUF
P3.1 TXD Serial data output SBUF
P3.2 INT0 External Interrupt 0 TCON.1
P3.3 INT1 External Interrupt 1 TCON.3
P3.4 T0 External Timer 0 I/P TMOD
P3.5 T1 External Timer 1 I/P TMOD
P3.6 WR External Memory write pulse -
P3.7 RD External Memory read pulse -
TMOD Register:
• Gate : When set, timer only runs while INT(0,1) is high.
• C/T : Counter/Timer select bit.
• M1 : Mode bit 1.• M0 : Mode bit 0.
TCON Register:
• TF1: Timer 1 overflow flag.• TR1: Timer 1 run control bit.• TF0: Timer 0 overflag.• TR0: Timer 0 run control bit.• IE1: External interrupt 1 edge flag.• IT1: External interrupt 1 type flag.• IE0: External interrupt 0 edge flag.• IT0: External interrupt 0 type flag.
Interrupts
Interrupt Enable Register :
• EA : Global enable/disable.• --- : Undefined.
• ET2 :Enable Timer 2 interrupt.• ES :Enable Serial port interrupt.• ET1 :Enable Timer 1 interrupt.• EX1 :Enable External 1 interrupt.• ET0 : Enable Timer 0 interrupt. • EX0 : Enable External 0 interrupt.
PROGRAM STATUS WORD
04/11/2023 CDAC,Mohali 22
Symbol Function
CY Used in arithmetic, jump, rotate & Boolean inst
AC Used for BCD arithmetic
F0 User flag 0
RS1 RS1 and RS0 used to select one of the 4
RS0 register banks of internal RAM
OV Used in arithmetic instructions
P Shows the parity of register A
CY AC F0 RS1 RS2 OV - P
Seven segment Interfacing
COMMANDS TO 7-SEGMENT
INSTRUCTION REGISTER
• CODE(HEX) COMMAND TO LCD INSTRUCTION REGISTER• 1 CLEAR DISPLAY SCREEN • 2 RETURN HOME • 4 DECREMENT CURSOR(SHIFT CURSOR TO LEFT) • 6 INCREMENT CURSOR(SHIFT CURSOR TO RIGHT) • 5 SHIFT DISPLAY RIGHT • 7 SHIFT DISPLAY LEFT • 8 DISPLAY OFF,CURSOR OFF • A DISPLAY OFF,CURSOR ON • C DISPLAY ON,CURSOR OFF • E DISPLAY ON CURSOR BLINKING • F DISPLAY ON CURSOR BLINKING • 10 SHIFT CURSOR POSITION TO LEFT • 14 SHIFT CURSOR POSITION TO RIGHT • 18 SHIFT THE ENTIRE DISPLAY TO THE LEFT • 1C SHIFT THE ENTIRE DISPLAY TO THE RIGHT • 80 FORCE CURSOR TO BEGINNING OF 1ST LINE • C0 FORCE CURSOR TO BEGINNING OF 2ND LINE • 8 2 LINES AND 5x7 MATRIX
LCD PIN DESCRIPTION
Pin No. Name Description Pin no. 1 D7 Data bus line 7 (MSB) Pin no. 2 D6 Data bus line 6 Pin no. 3 D5 Data bus line 5 Pin no. 4 D4 Data bus line 4 Pin no. 5 D3 Data bus line 3 Pin no. 6 D2 Data bus line 2 Pin no. 7 D1 Data bus line 1 Pin no. 8 D0 Data bus line 0 (LSB) Pin no. 9 EN1 Enable signal for row 0 and 1 (1stcontroller) Pin no. 10 R/W 0 = Write to LCD module 1 = Read from LCD module Pin no. 11 RS 0 = Instruction input 1 = Data input
Tie VEE (3) pin to 0V for maximum Contrast
THE FOLLOWING PROGRAM FEATURES:
» A DISPLAY » A TOGGLING LED &» A DICING 7-SEGMENT
org 00hacall LCDacall LEDacall DICELCD:mov a,#38hlcall commandmov a,#0fhlcall commandMov a,#01hLcall commandMov a,#80hLcall commandMov a,#’W’Lcall displayMov a,#’E’Lcall displayMov a,#’L’Lcall displayMov a,#’C’Lcall display1
Mov a,#’O’Lcall displayMov a,#’M’Lcall displayMov a,#’E’Lcall displayretCommand: lcall readyMov p1,aClr p3.2Clr p3.3Setb p3.4Clr p3.4RetReady: clr p3.4Clr p3.2Mov p1,#0ffhL1:setb p3.3Jb p1.7,L1Clr p3.4Ret
Display: lcall readyMov p1,aSetb p3.2Clr p3.3 Setb p3.4Clr p3.4RetDelay: mov r3,#25hHere: mov r1,#49hNopNopHere1:Djnz r1,here1Djnz r3,hereRetLED: mov p1, #00hLoop1: setb p1.2Acall delayClr p1.2Sjmp loop1retDICE: mov p1,#03fh
Acall delayMov p1,#06hAcall delayMov p1,#5bhAcall delayMov p1,#4fhAcall delayMov p1,#66hAcall delayMov p1,#6dhAcall delayMov p1,#7dhAcall delayMov p1,#07hAcall delayMov p1,#7chAcall delayMov p1,#67hAcall delayretend
CL
ICK
CL
ICK
SN
AP
THANKYOU!