The 8051 Microcontroller: Lets EXPLORE Inside 8051 !!
The document discusses the 8051 microcontroller. It provides an overview of microcontrollers versus microprocessors, the 8051 family and its features such as RAM, ROM, I/O ports. It describes the 8051 architecture including registers, programming model, interrupts and timers. Communication protocols like SPI, I2C and serial communication are also summarized.
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
77 views
The 8051 Microcontroller: Lets EXPLORE Inside 8051 !!
The document discusses the 8051 microcontroller. It provides an overview of microcontrollers versus microprocessors, the 8051 family and its features such as RAM, ROM, I/O ports. It describes the 8051 architecture including registers, programming model, interrupts and timers. Communication protocols like SPI, I2C and serial communication are also summarized.
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 45
The 8051 Microcontroller
Lets EXPLORE inside 8051 !!
Why MICROCONTROLLER ? Low cost compared to microprocessor Microcontroller is used for a specific or single task and microprocessor is used for general or any task No need to add other I/O devices as it is already built inside the microcontroller It is simple to program a microcontroller than a microprocessor
MICROCONTROLLERS vs. MICROPROCESSORS
CPU RAM ROM I/O PORT TIMER SERIAL PORT CPU RAM ROM I/O Timer Serial COM Port DATA BUS ADDRESS BUS MICROPROCESSOR
MICROCONTROLLER CISC AND RISC ARCHITECTURES Complex set instruction computer (CISC) Large number of instructions set Examples : Intel X86 microprocessors, AMD processors, 8051
Reduced instruction set computer (RISC) Small number of instructions set Examples : Atmel AVR, PIC microcontrollers
TYPES OF MICROCONTROLLERS There are many microcontrollers available in the market, some of the companies that manufacture the microcontrollers and their products are :
Freescale 6811 Zilog Z8 Intel 8051 Microchip PIC 16x Atmel AVR There are many controllers that are available in the market, some of the major manufacturers are: Atmel AVR series Microchip PIC series Intel 8051 series
Difference Between 8051 | AVR | PIC
In 1981, Intel introduced an 8-bit microcontroller called 8051 128 bytes of RAM, 4K bytes of on-chip ROM, two timers, one serial port & four I/O ports (8-bit wide) CPU Interrupt Control Oscillator ROM BUS Control RAM Timer 1 4 I/O Ports Serial Port Timer 0 External Interrupts TX RX P0 P1 P2 P3 Counter Input Introduction to 8051-(MCS-51) The other members of 8051 family are 8052 and 8031
*External ROM is added. **External I/O ports (e.g. 8255) can be added. Features 8051 8052 8031 ROM 4KB 8KB 0KB* RAM (in bytes) 128 256 128 TIMERS 2 3 2 I/O pins 32 32 32** SERIAL PORT 1 1 1 INTERRUPT SOURCES 6 8 6 Other Members of 8051 Family 8051: Pin Diagram
VCC : Supply voltage GND : Ground Port 0 Port 0 is an 8-bit open-drain bi-directional I/O port It may also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory External pull-ups are required when used as input
8051: Pin Description Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pull-ups It may also be configured to be the multiplexed low-order address/data bus during accessing the external program and data memory Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pull-ups Port 2 emits the high-order address during accesses to external data memory that use 16-bit addresses 8051: Pin Description Contd.. Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pull-ups
Port Pin Description (feature) P3.0 RXD (serial input port) P3.1 TXD (serial output port) P3.2 INT 0 (external interrupt 0) P3.3 INT 1 (external interrupt 1) P3.4 T0 (timer 0 external input) P3.5 T1 (timer 1 external input) P3.6 WR (external data memory write strobe) P3.7 RD (external data memory read strobe) 8051: Pin Description Contd.. RST : Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device EA/VPP External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH EA should be strapped to VCC for internal program executions 8051: Pin Description Contd.. Program counter points to the address of the next instruction to be executed: As the CPU fetches the opcode from the program ROM, the program counter is increasing to point to the next instruction
The program counter is 16 bits wide This means that it can access program addresses 0000 to FFFFH, a total of 64K bytes of code 8051: Program Counter The stack is a section of RAM used by the CPU to store information temporarily. This information could be data or an address.
The register used to access the stack is called the SP (Stack Pointer) register: The stack pointer in the 8051 is only 8 bit wide, which means that it can take value of 00 to FFH When the 8051 is powered up, the SP register contains value 07 RAM location 08 is the first location begin used for the stack by the 8051 8051: Stack Pointer n ! Hanged Computer! CPU Need to RESET or Restart the System RESET BUTTON Need of Reset n RESET BUTTON Reset in 8051 A watchdog timer is any hardware or software timer that automatically resets the C whenever any fault is observed.
This is same as the normal computer where you restart the PC if it is hanged. 8051: Watchdog Timer x CPU D0 D1 D2 D3 D4 D5 D6 D7 Parallel Communication x CPU D0 D1 D2 D3 D4 D5 D6 D7 Parallel Communication x CPU D0 D1 D2 D3 D4 D5 D6 D7 Parallel Communication x CPU D0 D1 D2 D3 D4 D5 D6 D7 Parallel Communication x CPU D0 D1 D2 D3 D4 D5 D6 D7 Parallel Communication x CPU D0 D1 D2 D3 D4 D5 D6 D7 Parallel Communication x CPU D0 D1 D2 D3 D4 D5 D6 D7 Parallel Communication x CPU START Serial Communication x CPU D0 Serial Communication x CPU D0 D1 Serial Communication x CPU D1 D0 D2 Serial Communication x CPU D2 D1 D0 D3 Serial Communication x CPU D3 D2 D1 D0 D4 Serial Communication x CPU D4 D3 D2 D1 D5 D0 Serial Communication x CPU D5 D4 D3 D2 D0 D6 D1 Serial Communication x CPU D7 D5 D4 D3 D2 D0 D6 D1 Serial Communication x CPU D7 D5 D4 D3 D2 D0 D6 D1 STOP Serial Communication x CY AC F0 RS1 RS0 OV - P RS1 RS0 Register Bank Address 0 0 0 00H 07H 0 1 1 08H 0FH 1 0 2 10H 17H 1 1 3 18H 1FH CARRY AUXILIARY CARRY USER DEFINED REGISTER BANK SELECTOR BIT 1 REGISTER BANK SELECTOR BIT 0 OVERFLOW PARITY USER DEFINED PSW (Program status word) x An interrupt is an asynchronous signal indicating need of attention or change in program execution.
PC e
ESC Escape button on Keyboard is an example of hardware interrupt 8051: Interrupts x PSW (Program status word) It is an 8-bit register and is also referred to as flag register Only 6-bits are used by 8051 and the two unused bits can be used by the programmer Four conditional flag bits : CY(carry) AC(auxiliary carry) P(parity) OV(overflow)
REGISTERS IN 8051 8051 has two timers T0 & T1 These are 16-bit wide They are accessed as two separate registers of low byte & high byte
8051: Timer | Counter 8 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 TH0 TL0 TH1 TL1 TIMER 0 Register TIMER 1 Register 8051: Timer Register Timer mode register is used to set the various timer operation modes Both timer 0 & timer 1 use the same register, called TMOD It is an 8-bit register The lower 4-bit are used for timer 0 & upper 4-bit are used for timer 1 The lower 2-bits are used to set the timer mode & upper 2-bits to specify the operation 8051: Timer Mode Register GATE C/T M1 M0 GATE C/T M1 M0 Timer 1 Timer 1 Timer 0 GATE : If 1 -> timer/counter is enabled only when interrupt is enabled 0 -> the timer is enabled whenever the TRx control bit is set
C/T : If 1 -> counter operation (input from Tx input pin) 0 -> timer operation (input from internal system clock) M1 M0 MODE Operating Mode 0 0 0 13-bit timer mode (8-bit timer/counter THx with TLx as 5-bit Prescaler) 0 1 1 16-bit timer mode (16-bit timer/counter THx and TLx are cascaded) 1 0 2 8-bit auto reload (8-bit auto reload timer/counter; THx holds a value which is to be reloaded TLx each time it overflows) 1 1 3 Split timer mode (256 +256 times) 8051: Timer Mode Register | Contd.. x UART : Universal a-synchronous receiver-transmitter Example RS-232, USB
USART : Universal Synchronous/Asynchronous Receiver/Transmitter Example I2C, SPI
UART / USART x Sometimes it is required to add some extra memory (ROM or RAM) to microcontroller.
The two dominant protocols are : Serial peripheral interface (SPI) and Inter integrated circuit (I2C).
SPI / I2C x The major differences are in the connections. SPI has a common bus of three wires, but it requires a separate select line for each device.
I2C has only two wires for all communications. Although the wiring is simpler for the I2C, the software is considerably more complex than that for the SPI.