Skip to content

Electronics · Ch 11 — Microcontroller

Chapter Summary

Chapter Summary

  • A microcontroller is a complete computer on one chip — a CPU with on-chip ROM, RAM, parallel and serial I/O, timers/counters, and interrupt and clock circuits — whereas a microprocessor is only the CPU and needs external memory and I/O. Microcontrollers are special-purpose controllers; microprocessors are general-purpose.
  • The 8051 is an 8-bit microcontroller with 4 KB ROM, 128 bytes RAM, two 16-bit timers (T0, T1), one serial port, four 8-bit ports (P0-P3, 32 I/O pins), a 16-bit program counter, registers A and B, five interrupt sources and a CISC instruction set. Its control registers are TCON, TMOD, SCON, PCON, IP and IE.
  • An addressing mode describes how an instruction finds its operand. The 8051 has five: register, direct, immediate, indirect (pointer via @R0/@R1) and base-plus-index. Direct addressing reaches all 128 bytes of RAM (00H-7FH) and the SFRs (80H-FFH).
  • The 8051 has 111 instructions in four groups: data transfer (MOV, MOVX, MOVC, PUSH/POP, XCH), arithmetic (ADD, ADDC, SUBB, INC, DEC, MUL AB, DIV AB, DA A), logical (ANL, ORL, XRL, CLR, CPL, RL/RR/RLC/RRC, SWAP) and program branching (jumps, calls and returns).
  • Assembly language is a low-level, mnemonic form of machine code, assembled into a .hex file through an editor → assembler → linker → object-to-hex toolchain. Directives such as ORG and END command the assembler, not the CPU.
  • On the 8051, arithmetic runs through the accumulator: ADD A,source; SUBB (clear carry first for a plain subtract; subtraction uses 2's complement); MUL AB (product low byte in A, high byte in B); and DIV AB (quotient in A, remainder in B; OV = 1 if B = 0).
  • The PIC (Peripheral Interface Controller) is a RISC microcontroller family from Microchip with just 35 instructions. The PIC16F887 offers 8 KB flash ROM, 256 bytes EEPROM, 368 bytes RAM, 0-20 MHz operation, 35 I/O pins, a 10-bit 14-channel ADC, three timers, comparators, PWM, an enhanced USART and MSSP. …