Beruflich Dokumente
Kultur Dokumente
0145
0146
00
30
91
0147
FD
0148
0149
D2
90
014A
014B
31
52
014C
014D
C2
90
014E
014F
31
52
0150
0151
0152
0153
0154
80
F3
78
C8
D8
0155
0156
FE
22
JNB 91H, FD H
SET B , ; set direct 90H
JNB P1.3,LABEL
BIT ADRESS
ACALL
CODE ADDRESS
MOV R5,A
SET B
BIT ADDRESS
DPTR,#IMMED
ACALL addr 11
ANL A, data
addr
CLR bit
BIT ADDRESS
DPTR,#IMMED
ACALL addr 11
ANL A, data
addr
SJMP code addrs
MOVX R1,A
MOV R0,#data
XCH A,R0
DJNZ RO, code
adres
MOV R6,A
RET
; jump
1. Move the value in the program counter to the memory address register
2.
3. Send the value in the memory address register to memory via the address
bus
4. Return the value stored in memory via the data bus
5. Store the value in the memory data register
6. Copy the instruction from the memory address register to the instruction
register
7. Increment the program counter. The instruction in the instruction register is
then Decoded
Execute Sequence
Delay required
= (x +y + 25) milli seconds
= 915 + 714 + 25 = 1654 ms
one machine cycle
= 12 oscillations
frequency of the clock
= 11.0592 MHz
therefore on machine cycle
= 12/11.0592
= 1.085 s
for a DJNZ no of machine cycles = 2
for a DJNZ time delay
= 2*1.085
=
2.17 s
therefore no of DJNS
= 1654ms/2.17
s
=
762212
finding values for registers since maximum data value on a register is 255H
762212/255 =2989
2989/255 = 12
Delay :
MOV R1, #12
Label1:
MOV R2, #255
Label2:
MOV R3, #255
Loop :
DJNZ R3, Loop
DJNZ R2, Label2
DJNZ R1. Label1
RET
PART 2 @@@@@@@@222
LET CLOCK FREQUENCY IS 11.0592MHz
= 1/(11.0592/12)
= 1.085 s
= (X + Y + 25)s
= 915+714+25
= 1654ms
= 1654 ms / 1.085 s
= 1524424
oscilla
tor
/12
TR
TR
set TL &
TH &
value
for
multipli
er(R0
TF
The mikroC PRO for 8051 has two memory type specifiers that refers to external memory
space: xdata and pdata.
SFR Memory
The 8051 provides 128 bytes of memory for Special Function Registers (SFRs). SFRs are bit,
byte, or word-sized registers that are used to control timers, counters, serial I/O, port I/O,
and peripherals.
MOV
In the 8051 the MOV instruction is concerned with moving data internally, i.e.
between Internal RAM, SFR registers, general registers etc. MOVX and MOVC are
used in accessing external memory data. The MOV instruction has the following
format:
MOV destination <- source
The instruction copies (copy is a more accurate word than move) data from a
defined
source location to a destination location. Example MOV instructions are:
MOV R2, #80h ; Move immediate data value 80h to register R2
MOV R4, A ; Copy data from accumulator to register R4
MOV DPTR, #0F22Ch ; Move immediate value F22Ch to the DPTR register
MOV R2, 80h ; Copy data from 80h (Port 0 SFR) to R2
MOV 52h, #52h ; Copy immediate data value 52h to RAM location 52h
MOV 52h, 53h ; Copy data from RAM location 53h to RAM 52h
MOV A, @R0 ; Copy contents of location addressed in R0 to A
(indirect addressing)
MOVX
The 8051 the external memory can be addressed using indirect addressing only. The
DPTR register is used to hold the address of the external data (since DPTR is a 16bit
register it can address 64KByte locations: 216 = 64K). The 8 bit registers R0 or R1
can
also be used for indirect addressing of external memory but the address range is
limited to the lower 256 bytes of memory (28
= 256 bytes).
8051 Tutorial D.Heffernan 2000, 2001 23
The MOVX instruction is used to access the external memory (X indicates eXternal
memory access). All external moves must work through the A register
(accumulator).
Examples of MOVX instructions are:
MOVX @DPTR, A ; Copy data from A to the address specified in DPTR
MOVX A, @DPTR ; Copy data from address specified in DPTR to A
MOVC
MOVX instructions operate on RAM, which is (normally) a volatile memory.
Program tables often need to be stored in ROM since ROM is non volatile memory.
The MOVC instruction is used to read data from the external code memory (ROM).
Like the MOVX instruction the DPTR register is used as the indirect address register.
1. Text Editor
This is where you will compose the code that ultimately will run on
your 8051 board and make you project function. All PC operating
systems include a text editor, and there are many free text editors
available on the internet. PJRC does not provide a text editor. All
Microsoft Windows systems have NOTEPAD, which is a very simple
editor. Linux systems usually have VI and EMACSinstalled, as well as
several others.
2. Compiler or Assembler
Your source code will be turned into a .HEX file by either an Assembler
or Compiler, depending on your choice of programming language. PJRC
provides free downloads of the AS31 assembler and SDCC C Compiler.
These free tools are available for Linux-based Systems and Microsoft
Windows. It is also possible to use other compilers, such as the Keil C
compiler.
3. Terminal Emulator
To communicate with your 8051 board, you must run a terminal
emulator program. You will be able to transmit your .HEX file to the
board and run its code, observe its results and information it may send
to the serial port, and you can also use the terminal emulator to
examine and manipulate memory with the Monitor ROM. Microsoft
provides HyperTerminal with windows (often it must be installed from
the windows cdrom using "add/remove programs"). Linux distributions
usually provide minicom.
4. Monitor ROM
The Monitor ROM is 8051 code that runs when your board boots. It
provides interactive menus that allow you to download code, run it,
manipulate memory and perform other functions. All 8051
development boards from PJRC come with PAULMON2 loaded in the
non-erasable internal memory of the 87C52 chip. Using the monitor,
you can cause your code to run on the board. It is also possible to
download your code to non-volatile memory on the board together
with a "auto-start header" that causes PAULMON2 to run your code
automatically when the board boots.
availability and reliable sources
of the microcontroller
The 8051 family has the largest number of diversified (multiple source) suppliers
Intel (original)
Atmel
Philips/Signetics
AMD
Infineon (formerly Siemens)
Matra
Dallas Semiconductor/Maxim