8051 MC
8051 MC
8051 MC
https://youtu.be/T1C9Kj_78ek
• Port-1 does not have any alternate function i.e. it is dedicated solely 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.
Port-2 Pin Structure
If the program memory is external , 16 I/O lines are used for accessing the external
memory.
Port 0 and Port 2 are used for external memory accessing, where initially Port 0 send
lower order address when ALE signal of 8051 is high and then it function as input port for
data transfer from the corresponding memory location while Port 2 sends higher order
address.
Internal Memory
Register Organisation
Special Function Register(SFR)
• The SFR registers are located within the Internal Memory in the address
range 80h to FFh. Not all locations within this range are defined.
• Each SFR has a very specific function. Each SFR has an address (within the
range 80h to FFh) and a name which reflects the purpose of the SFR.
• Although 128 byes of the SFR address space is defined only 21 SFR
registers are defined in the standard 8051.
• Undefined SFR addresses should not be accessed as this might lead to
some unpredictable results. Note some of the SFR registers are bit
addressable. SFRs are accessed just like normal Internal RAM locations.
PSW Program Status Word ( flag register)
Auxiliary conventional auxiliary carry Even Parity accumulator parity flag (even
Flag(AC): (half carry) flag(P): parity)
Flag 0.(F0): general-purpose flag RS0 and RS1 active register bank
SFR Registers for the Internal Timer
TCON :
• The Timer Control register is an SFR at address 88h, which is bitaddressable.
TCON is used to configure and monitor the 8051 timers. • The TCON SFR also
contains some interrupt control bits, described later.
TMOD:
The Timer Mode register is an SFR at address 89h and is used to define the
operational modes for the timers.
TL0 (Timer 0 Low) and TH0 (Timer 0 High) are two SFR registers addressed at 8Ah
and 8Bh respectively. The two registers are associated with Timer 0.
TL1 (Timer 1 Low) and TH1 (Timer 1 High) are two SFR registers addressed at 8Ch
and 8Dh respectively. These two registers are associated with Timer 1.
Power Control Register
PCON (Power Control) register is an SFR at address 87h. It contains various control
bits including a control bit, which allows the 8051 to go to ‘sleep’ so as to save
power when not in immediate use.
Serial Port Registers
SCON (Serial Control) is an SFR register located at addresses 98h, and it is bit
addressable. SCON configures the behaviour of the onchip serial port, setting up
parameters such as the baud rate of the serial port, activating send and/or receive
data, and setting up some specific control flags.
SBUF (Serial Buffer) is an SFR register located at address 99h. SBUF is just a single
byte deep buffer used for sending and receiving data via the on-chip serial port.
Interrupt Registers
• IE (Interrupt Enable) is an SFR register at addresses A8h and is used
to enable and disable specific interrupts. The MSB bit (bit 7) is used
to disable all interrupts.
• IP (Interrupt Priority) is an SFR register at addresses B8h and it is bit
addressable. The IP register specifies the relative priority (high or
low priority) of each interrupt. On the 8051, an interrupt may either
be of low (0) priority or high (1) priority.
Programming embedded
systems
Structure of embedded program
Infinite loop
Compiling
Linking and debugging
Structure of embedded program
The embedded C program has a structure similar to C programming.
The five layers are:
• Comments
• Pre-processor directives
• Global declaration
• Local declaration
• Main function()
Preprocessor Directives Section:
• The Pre-Processor directives tell the compiler which files to look in to
find the symbols that are not present in the program.