Title: Introduction to Microprocessors
1Introduction to Microprocessors
- CEC 320
- Review for Exam 1
2Administrative
- CEC 322 lab is Thursdays 125 to 405
- KETC 130
- There is a prelab Go to the CEC 322 WEB site
- Homework Read the section on Basic 8051 Core
3Basic Microprocessor Core
4Block Diagram of the 8051 Core
58051 internal RAM Organization
- Notice there are 4 register banks, 8 registers
each - This was done when all programming was done in
assembly - Notice that there is a bit addressable space
- Register Bank Switching greatly facilitated
Assembly language programming of interrupts - Today, the 3 extra memory banks are used by C
to pass parameters and assign temporary variables
6Basic 8051 Pin Configuration
- Notice that many of the port pins have multiple
purposes
7Things to Remember
- The 8051 engine uses separate code memory and
data memory - The basic 8051 core has
- 4 eight bit I/O ports
- 2 built in timers that can be configured as
counters - Built in serial communications facility
- Built-in interrupt controller 5 basic
interrupts are native - Built-in clock oscillator circuit
- The internal data memory is very limited
- Must be shared with all registers
- Must be shared with the stack
- Internal code memory can be 2K, 4K, 8K or larger
depending on the particular model chip - The 8051 was designed to address 64K code memory
and 64K data memory through the use of external
chips - Using external memory sacrifices most of 3 I/O
ports - All registers are mapped into the internal data
memory space - The 8051 uses an Accumulator based instruction
set architecture - Most modern microprocessors use a Register Based
instruction set
8Pop Quiz 10 minutes Closed book
- What memory architecture does the 8051 use.
- What is the other memory architecture
- What is the difference
- Name 3 peripheral functions (there are more)
contained on the basic 8051 chip that are not
normally found on general purpose microprocessor
chips
9Pop Quiz 10 minutes Closed note book
- Why do we have interrupts
- What happens when an interrupt occurs
- What happens when in interrupt completes
108051 Timers
- The 8051 has two built-in Timers
- Each Timer can operate in any of 3 normal modes
and one combined mode - 13 bit timer mode
- 16 bit timer mode
- 8 bit auto reload mode
- Split Timer Mode
- The mode control register is TMOD
- TMOD is NOT bit addressable
11TMOD
12TCON
13Timer Mode 2
- 8 bit auto reload
- Timer increments once per machine cycle (12 clock
cycles) - An interrupt is generated upon overflow
- Timer 0 vectors to interrupt location 1
- Timer 1 vectors to interrupt location 3
14Each Timer Registers
- Each Timer has two (2) eight bit registers
- labeled TL0 and TH0 for Timer 0
- labeled TL1 and TH1 for Timer 1
- The TL(X) register is incremented each machine
cycle - Machine cycle is clock/12
- Upon overflow, the TL(X) register is reloaded
with the value in TH(X) and - An Interrupt is generated
- There are no lost machine cycles
15Important Timing Considerations
- The maximum number of machine cycles between
interrupts is 256 - The ISR must complete its work within the 256
cycles to avoid recursion - Problem is much more complex if more than one
interrupt is running at the same time - All of the time spent in a timer ISR is
unavailable for other work the microprocessor may
be tasked with
16Interrupt Enable Register IE
17IE Bit Labels
18Pop Quiz 10 minutes Closed note book
- Assuming
- We want to operate Timer 0 in 8 bit auto reload
mode (mode 2) - We want interrupts to occur every 100 mS
- Clock crystal is 22.118 MHz
- What is the timer reload value we need
- Show your calculations
19Serial Communications 1 bit at a time
- We can send data synchronously
- Or not (Asynchronous)
- Either way we have to know where the bits are
otherwise they all look the same
20Common RS232 byte frames
- BAUD rate refers to the bit time rate data is
being transferred - 9600 BAUD means 9600 bit times per second
- Standard RS 232 Baud rates are
- 9600
- 4800
- 2400
- 1200
- 300
- 120 (very slow)
21It takes more bit times than bits to create a
serial byte frame
- Refer to the diagram Im about to draw on the
board (this shows 10 bit times per byte of data
the most common case)
22Each bit time is divided into 16 clock states
- Usually a UART will have a prescale register so
that what ever crystal you chose will produce 16
clock states at your chosen Baud rate. - Only certain specific crystal frequencies will
produce exactly 16 clock states at any common
Baud rate - Thats why we use the 11.0592 MHz and 22.118 MHz
crystals for the 8051
23Matching UARTS
- The transmitting UART and the Receiving UART must
be configured to produce the same clock state
frequency (almost) in order to communicate - Almost means there is an allowable error in
frequency match
24How the Transmitter and Receiver synchronize
- The 16 clock state generators must closely match
- The leading edge of the start bit from the
Transmitter starts clock state counting in the
Receiver - From that point forward (10 bit times), the
transmitter and Receiver must not differ by more
than 1 or 2 clock state counts
25SCON
26Input Buffering
- The receive state machine has a receive holding
register - As soon as an incoming byte is received, the data
byte is transferred to the holding register so
that the next data byte can be clocked in - The microprocessor has until the second byte is
clocked in to read the first byte and clear the
holding register
27Output Buffering
- The Transmit State Machine has an output holding
register - By keeping the output holding register serviced,
maximum byte transfer rate can be maintained
28Hand Shake
- What if the receiving UART is full?
- Hardware handshake allows the receiving UART to
pause or delay transmission of data bytes - This is useful if the microprocessor is busy
- Two means of hardware handshake are available on
the 8250 - There is no hardware handshaking on the 8051
29Things to Remember (Know)
- Draw and explain the RS 232 byte frame
- How does the Receiver synchronize with the
transmitter - What is handshaking
- What are the strengths and weaknesses of
- Asynchronous Communications (RS 232)
- Synchronous communications (like USB and others)