Unit 1 All Notes Combined
Unit 1 All Notes Combined
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) 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.
EXTRA –
How does the microcontroller handle external memory depends on the pin EA logical
state.
When EA = 0,
- then 8051 is completely ignored the internal program memory.
- It start the execution of a program stored in external memory.
When EA = 1,
- 8051 execute a program from internal ROM and
- After that execution is continued by executing the program from additional memory.
In both cases, P0 and P2 are used for data and address transmission, so they can not used
as normal I/O port.
e.g., MOV C,P1.0; data on port pin P1.0 will be copied in carry flag
Power down and Idle mode features are used to save power in microcontrollers. 8051
has an inbuilt power-saving feature which is useful in embedded applications where
power consumption is the main constraint.
There is a SFR ( last SFR in our list ) for power control mode in 8051. Only two bits in
the register are related to power saving mode in 8051 ( PD, IDL ).
PD IDL Status
0 0 Normal Power mode
0 1 Idle mode
1 0 Power down mode
1 1 Power down mode
Whenever the processor restarts by default it is in normal mode. The figure below depicts
the PCON ( power control ) register.
8051 Power Control Logic
IDLE MODE
In the Idle mode, the internal clock signal is cut from the CPU, but not to the
Interrupt, Timer and Serial Port functions.
The CPU status is preserved in its entirety, the Stack Pointer, Program Counter,
Program Status Word, Accumulator, and all other registers maintain their data
during Idle.
The port pins hold the logical state they had at the time idle mode was activated.
ALE and PSEN hold at logic high levels.
In this mode 80% of power is saved. The 20% power is used to get the
microcontroller from idle mode to normal mode.
1) Activation of any enabled interrupt will cause PCON.O to be cleared and idle
mode is terminated.
2) Hard ware reset: that is signal at RST pin clears IDEAL bit IN PCON register
directly. At this time, CPU resumes the program execution from where it left off.
POWER DOWN MODE
In this mode, clock supply is cut from the whole system. In this power
saving mode maximum amount of power is saved.
OR In the Power Down mode, the on-chip oscillator is stopped. With the clock
frozen, all functions are stopped, but the on-chip RAM and Special Function
Register are maintained held.
The port pins output the values held by their respective SFRS. ALE and PSEN are
held low.
1. Restart
In this method, the system is restarted, and the previous data is lost.
As shown in the above figure of 8051 power control logic, two control bits are there, IDL
and PD, which are used for Idle and Power-down mode respectively.
In Power Down mode, the oscillator clock provided to the system is OFF i.e. CPU and
peripherals clock remains inactive in this mode.
In Idle Mode, only the clock provided to the CPU gets deactivated, whereas the
peripherals clock will remain active in this mode.
The below table shows the power supply current required for 8051 family controllers in
Normal (Active), Idle and Power-down mode.
Parameter Power Down Mode Idle Mode
Initialized by setting PCON.1 PCON.0
By Hardware Reset Any Enabled Interrupt or Hardware
Terminated By
Only Reset
Current 6.5mA 50uA
Condition of
Reinitialized Remain Unchanged
SFRs after Exit
Condition of Internal RAM Unchanged Unchanged
Condition of Ports during
Unchanged Unchanged
Sleep
On-Chip Oscillator Inactive Active
CPU status Inactive Inactive
As per the above table, it is clear that power consumption in power-down mode is less
than in Normal or idle mode.
8051 I/O port Structure –
I /O PORTS
To communicate data with the external world the microcontroller needs ports.
The ports may support either parallel or serial data transfer.
It has 4 I/O ports namely, Port 0, Port 1, Port 2 & Port 3
Port 1: is exclusively for input & output functions.
Port 0, 2 & 3: perform functions other than parallel data transfer.
All 4 ports are bidirectional.
The 8 port pins are connected through 8 D type port latches.
Each port has 8 pins. Thus the four ports jointly comprise 32 pins.
All ports are bidirectional.
They are constructed with a D type output latch. They have output drivers and input
buffers.
We can modify their functions using software and hardware that they connect to.
All the ports are configured as input ports on Reset.
To configure ports as an input port 1 must be written to that port
To configure it as an output port 0 must be written to it.
PORT 0:
Functions of Port 0 –
Address is 90H
Construction: Port 1 has one D latch, two unidirectional buffers, 1 FET,
and one internal pull-up resistor at each pin.
It has only one function – to act as an Input-Output port.
Explanation -
Port-1 has 8 pins (P1.1-P1.7)
Port-1 does not have any alternate function i.e. it is dedicated only for I/O
interfacing.
When used as output port, the pin is pulled up or down through internal pull-up.
To use port-1 as input port, '1' has to be written to the latch. In this
input mode when '1' is written to the pin by the external device then it read
line.
But when '0' is written to the pin by the external device then the
external source must sink current due to internal pull-up.
If the external device is not able to sink the current the pin voltage may
rise, leading to a possible wrong reading.
Port 2 :
Port-2 has 8-pins (P2.0-P2.7)
Port-2 is used for higher external address byte or a normal input/output port.
The I/O operation is similar to Port-1.
Port-2 latch remains stable when Port-2 pin are used for external memory access.
Here again due to internal pull-up there is limited current driving capability.
Functions of Port 2
Port-2 is used for higher external address byte or a normal input/output port. The I/O
operation is similar to Port-1.
PORT 3:
Port-3 has 8 pin (P3.0-P3.7)
Port-3 pins have alternate functions.
Each pin of Port-3 can be individually programmed for I/O operation
or for alternate function.
The alternate function can be activated only if the corresponding latch
has been written to '1'.
To use the port as input port, '1' should be written.
Functions of Port 3-
Agenda of meeting is
Date: 31/03/2023
Time: 12:30pm