Week 4 Flashcards
What is a microcontroller?
A microcontroller is a complete computer system built on a single chip. A typical microcontroller includes a microprocessor, memory, I/O and other peripherals on a single chip
Use of microcontrollers?
Microprocessors work with a bunch of supporting hardware such as memory and ICs.
The computational power, complexity and power consumption kept on increasing in order to provide the ultimate performance.
However, sometimes the emphasis is not on the computational power but rather on the a control mechanism with less complex hardware and increased reliability.
Von Newmann Architecture
One shared program for data and memory
One common bus for instruction and data transfer
Instruction fetch and data operation cannot occur at the same time which is the limitation of the architecture
Harvard architecture
Separate memory units for instructions and data
Separate buses for instruction and data access
CPU can access instructions and read/write data simultaneously
Naturally suit microcontrollers
I/O and other peripherals
Microcontrollers features I/O pins to implement peripheral functions such as:
-GPIO (general purpose I/O)
-Timer/counter
-ADC (Analog-to-digital display)
-LCD (liquid crystal display)
-RTC (real time clock)
-Communications such as USB
Clock signals
They govern speed and synchronise actions
Oscillators are responsible for supplying the clock signals in microcontrollers
Clock sources include:
- External sources like typical crystal oscillators, high reliability, more costly
- Internal sources mostly RC oscillators are convenient and not as stable
PLL (phase lock loop) module for frequency multiplication
Clock signals
They govern speed and synchronise actions
Oscillators are responsible for supplying the clock signals in microcontrollers
Clock sources include:
- External sources like typical crystal oscillators, high reliability, more costly
- Internal sources mostly RC oscillators are convenient and not as stable
PLL (phase lock loop) module for frequency multiplication
Timer/Counter
A special piece of hardware inside MPUs
One essential feature in any MPU
Timer/Counter
A special piece of hardware inside MCUs
One essential feature in any MPU
To measure time intervals/number of count, produce time delay, produce PWM
At the heart a register increments/decrements by 1 on every input signal
-Timers use the frequencies of the internal clocks
-Counters use external signals to count pulses
Timer Register
The MCU has a timer module integrated in it which has a timer counter register in it which could be any size (8 bit, 16 bit etc)
Example: How long does it take before overflow?
5Hz input pulses to the time counter register; 8 bit timer starts from 252.
1 input pulse takes 1/5=0.2s
256-252=4 pulses before overflow
0.2*4=0.8 seconds
8051 MCU
C/T: choose whether to use as a timer or a counter
TR1: enable/disable the timer
GATE: internal/external control
TL1/TH1: Timer 1 timer/counter register
TF1: set when there is an overflow. TF=1 would trigger interrupt if the interrupt is enable
Post-Scalar
Most MCUs come with post scalar in timers
A post scalar defines how many times a timer overflows before an interrupt is generated
Period Register
Consists of a value set by the user which is continuously compared with the value in the main timer register