5.1 Into To Microcontroller
5.1 Into To Microcontroller
Introduction to Microcontrollers
• A microcontroller (MCU) is a small computer on
a single integrated circuit consisting of a
relatively simple central processing unit (CPU)
combined with peripheral devices such as
memories, I/O devices, and timers.
– By some accounts, more than half of all CPUs sold
worldwide are microcontrollers
Die shot of a microcontroller
Microcontroller VS Microprocessor
• A microcontroller is a small computer on a
single integrated circuit containing a
processor core, memory, and programmable
input/output peripherals.
• A microprocessor incorporates the functions
of a computer’s central processing unit (CPU)
on a single integrated circuit.
Microcontroller VS Microprocessor
Types of Processors
• In general-purpose computing, the variety of
instruction set architectures today is limited, with
the Intel x86 architecture overwhelmingly
dominating all.
• There is no such dominance in embedded
computing. On the contrary, the variety of
processors can be daunting to a system designer.
• Things that matter
– Peripherals, Concurrency & Timing, Clock Rates,
Memory sizes (SRAM & flash), Package sizes
Types of Microcontrollers
How to choose MCU for our project?
– Internal functions
• Migrating data from the sensor to the radio (DMA)
How to choose MCU for our project?
• Memory
– Store accelerometer history data
• 12bits each for X,Y,Z acceleration
• sampled 2 thousand times a second (2 KHz)
• = 12*3*2,000 bits per second (72kbits or 9 kBytes)
• How many seconds can we hold if we have only 100 kBytes of storage
– What types of memory are available on an MCU?
• Internal memory: RAM, 0.5~128 kBytes
• External memory: Flash, high power consumption, ~5mA for read and
~10mA for erase
How to choose MCU for our project?
• Clock frequency
– kHz is too slow
• Smartphone camera frame rate is 60fps
(1 KHz clock would leave only 60 clock cycles per frame)
• Large diversity
– Many widely differing device types
– Devices within each type also differs
• Speed
– varying, often slow access & transfer compared to CPU
– Some device-types require very fast access & transfer
• Access
– Sequential VS random
– read, write, read & write
What operations does software
need to perform on peripherals?
1. Get and set parameters
2. Receive and transmit data
3. Enable and disable functions
How can we imagine providing an
interface to hardware from software?
•GPIOs can be used to control lights (light on or off), but even more
•Debugging
– Did this one part of my code actually execute?
– Is the timer firing at the interval that I expect it to fire (connect GPIO to oscilloscope)?
– Why using GPIO?
• GPIO ops are lightweight
Topology of a GPIO pin
GPIO Configurations
A fun extra feature: Drive Strength