Professional Documents
Culture Documents
Intro To Msc51
Intro To Msc51
In this module, we will be discussing the MCS-51 family of microcontroller, in particular the 8051, which is the generic IC representative of this family.
FIGURE 21
Pin Layout
The 8051 is a 40 pin device, but out of these 40 pins, 32 are used for I/O. 24 of these are dual purpose, i.e. they can operate as I/O or a control line or as part of address or date bus.
FIGURE 22
8051 pinouts
RST (Reset) This is pin 9 of the IC and is used as the master reset for the 8051. In order for the 8051 to recognise that a reset has occurred, this pin must be brought HIGH for at least two machine cycles. During normal operation, this pin must be at logic LOW. This will be discussed in more detail later.
Oscillator ( clock) Input The 8051 is typically driven by a crystal oscillator connected to pin 18 and 19 as shown in fig.2-3. The words XTAL is short for crysTAL.
FIGURE 23
Power Connections
The 8051 requires a +5V input on its Vcc input (pin 40) and Vss connection is on page 20.
FIGURE 24
FIGURE 25
Relationship between oscillator clock cycles, states, and the machine cycle
Memory Structure
While most microprocessors implement a shared memory space for data and code (programs), microcontrollers has limited memory and the program is usually stored in ROM. In the 8051, both code and data may be internal but they are stored in separate memories, namely the internal ROM and RAM. Expandable to a max of 64K using external memory. The next page shows the 8031 which has no internal ROM.
FIGURE 26
FIGURE 27
Register Banks
4 Register Banks Bank0, Bank1, Bank2 and Bank3 Each Bank consists of R0, R1, R2, R3, R4, R5, R6, R7 Bank 0 is the default upon power up of the microcontroller Other banks can be selected by programming PSW register.
Bit-Addressable RAM
The 8051 contains 210 bit-addressable locations of which 128 are at byte address 20H through 2FH as shown in fig 2-7. This is the powerful feature of most microcontroller because individual bits can be set, cleared, ANDed, ORed etc. with a single instruction instead of having to read a byte and modify
Example
we could issue a simple instruction
SETB 67H This would set the bit at address 67H to logic HIGH. Bit 67H is bit 7(most significant bit) of byte location 2CH In order to achieve the same result, a microprocessor would need to do this: MOV A, 2CH ORL A,#10000000B MOV 2CH,A
SFRs
SFR are usually addressed by name Memory location 0F0H is given a name called Register B, similarly 80H is called P0. Not all memory location has a name
memory location 35H has no name
Some locations between the SFRs have no names as well e.g. 91H. Such locations should not be used to store any data. If you do it then your data may be lost. Some important or commonly used SFRs will be discussed while others will be explained when you need to use them in your projects.
80C31
ALE/PROG PSE N A15 P2.7 A14 P2.6 A13 P2.5 A12 P2.4 A11 P2.3 A10 P2.2 A9 P2.1 A8 P2.0
FIGURE 28
FIGURE 29
FIGURE 210
FIGURE 211
FIGURE 212
Interface to 1K RAM
Reset Operation
To reset the 8051, the RST pin must be held high for at least 2 machine cycles. This can be achieved upon powerup using an RC network. Fig.2-16 shows 2 circuits for achieving this, one is a manual reset, the other is a poweron reset. How does the 2 circuit works?
Try to remember capacitor is open during steady-state.
FIGURE 216
Two circuits for system reset. (a) Manual reset (b) Power-on reset.