Sie sind auf Seite 1von 9

0145

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

1. The instruction is Executed

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

machine cycle delay


time delay required
No of machine cycles required

= 1/(11.0592/12)
= 1.085 s
= (X + Y + 25)s
= 915+714+25
= 1654ms
= 1654 ms / 1.085 s
= 1524424

finding TH1 and TL1 values


Since the timer count's up
65536(ffffH) -34624
= 30912 = 78C0
Examine the following program and find the time delay in seconds.
Exclude the overhead due to the instructions in the loop.
MOV TMOD,#10H ;Timer 1, mod 1
HERE: MOV R0,#44 ; multiple delay
AGAIN:
MOV TL1,#78H
; low byte
MOV TH1,#C0H
; high byte
SETB TR1
;Start timer 1
BACK: JNB TF1,BACK
;until timer rolls over
CLR TR1
;Stop the timer 1
CLR TF1
;clear Timer 1 flag
DJNZ R0,AGAIN
;if R0 not zero then reload timer

when TF goes high

clear the flag and

oscilla
tor

/12
TR
TR

set TL &
TH &
value
for
multipli
er(R0

wht is timer configuration diagram????????????????????

MOV TMOD,#10H ;Timer 1, mod 1


MOV R0,#44;cnter for multiple delay
AGAIN: MOV TL1,#78H ; low byte

TF

MOV TH1,#0C0H ; high byte


SETB TR1 ;Start timer 1
BACK: JNB TF1,BACK ;until timer rolls over
CLR TR1 ;Stop the timer 1
CLR TF1 ;clear Timer 1 flag
DJNZ R0,AGAIN ;if R0 not zero then
CPL P1.0;reload timer
The 8051 microcontroller's memory is divided into Program Memory and Data Memory.
Program Memory (ROM) is used for permanent saving program being executed, while Data
Memory (RAM) is used for temporarily storing and keeping intermediate results and
variables.

Program Memory (ROM)


Program Memory (ROM) is used for permanent saving program (CODE) being executed. The
memory is read only. Depending on the settings made in compiler, program memory may
also used to store a constant variables. The 8051 executes programs stored in program
memory only. code memory type specifier is used to refer to program memory.
8051 memory organization alows external program memory to be added.
How does the microcontroller handle external memory depends on the pin EA logical state.

Internal Data Memory


Up to 256 bytes of internal data memory are available depending on the 8051 derivative.
Locations available to the user occupy addressing space from 0 to 7Fh, i.e. first 128
registers and this part of RAM is divided in several blocks. The first 128 bytes of internal
data memory are both directly and indirectly addressable. The upper 128 bytes of data
memory (from 0x80 to 0xFF) can be addressed only indirectly.
Since internal data memory is used for CALL stack also and there is only 256 bytes splited
over few different memory areas fine utilizing of this memory is crucial for fast and compact
code. See types efficiency also.
Memory block in the range of 20h to 2Fh is bit-addressable, which means that each bit
being there has its own address from 0 to 7Fh. Since there are 16 such registers, this block
contains in total of 128 bits with separate addresses ( Bit 0 of byte 20h has the bit address

0, and bit 7 of byte 2Fh has the bit address 7Fh).


Three memory type specifiers can be used to refer to the internal data
memory: data, idata, and bdata.

External Data Memory


Access to external memory is slower than access to internal data memory. There may be up
to 64K Bytes of external data memory. Several 8051 devices provide on-chip XRAM space
that is accessed with the same instructions as the traditional external data space. This
XRAM space is typically enabled via proper setting of SFR register and overlaps the external
memory space. Setting of that register must be manualy done in code, before any access to
external memory or XRAM space is made.

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.

The indirect addressing is enhanced to realise an indexed addressing mode where


register A can be used to provide an offset in the address specification. Like the
MOVX instruction all moves must be done through register A. The following
sequence of instructions provides an example:
MOV DPTR, # 2000h ; Copy the data value 2000h to the DPTR register
MOV A, #80h ; Copy the data value 80h to register A
MOVC A, @A+DPTR ; Copy the contents of the address 2080h (2000h + 80h)
; to register A
Note, for the MOVC the program counter, PC, can also be used to form the address.

Study.pdf page 15 upto


For each tool, there you may choose on of several options. The basic tools are:

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

Das könnte Ihnen auch gefallen