Microcontroller concepts Flashcards
What is the hosting application/hardware setup of a MCU?
- Power Supply
- Oscillator
- Programmer (+debugger)
- Most applications also need peripherals
Datapath
Datapath is a collection of registers (fast memory) and a set of microoperations on the data
Control
Directs the ordered execution of the microoperations, to get the desired transformation
How many buses do normal systems have?
3 Buses:
- Data holds the data itself
- Address indicates where to store (or read) the data
- Control specifies how the data is transported
Width of the buses specifies the amount of data that can be transferred in 1 clock cycle
What are the steps comprised in an instruction cycle?
Fetch: retrieve instructions from memory and save to IR (Instruction Register)
Decode: Extract the operation code from the instruction and decode it
Execute: Perform the sequence of steps necessary to execute the instruction
Next: Adjust value of PC (program counter)
What is RAM and what are some of its features?
Random Access Memory
- Normal RAM is volatile and loses information without power.
- Often used for changing data (e.g. variables)
- Fast
What is ROM and what are some of its features?
Read Only Memory
- Non-volatile memory
- Used for code
- Limited number of write cycles
- Typically slower than RAM
What is the goal of a program? What are some metrics for memory?
Execute as quickly as possible
Metrics:
- Access time
- Storage capacity
What is the benefit of having multiple buses that access the same memory?
It means that the memory point can be accessed simultaneously and you don’t have to wait for the bus to become available (this reduces latency)
What is the benefit of using STM32Cube?
STM32Cube generates all initialization code automatically
How does RAM differ from a register file (RF)?
RAM is typically larger (storage size)
RAM stores data using a bit storage approach
What are the differences between Register files (RFs), SRAM and DRAM?
RF:
- Fastest
- Biggest Size
SRAM:
- Fast
- More compact than RFs
DRAM:
- Slowest (& refreshing takes time) Refreshing is the regular reading of something then writing it back to avoid dissipation
- Very compact
What size items should be used for RFs, SRAM and DRAM?
RFs - small items
SRAM - Large items
DRAM - Huge items (DRAM’s big capacitor requires special chip design process)
What is cache?
Small fast memory, that temporarily holds copies of block data
~10x faster than main memory
if instructions are present in cache, they can be executed much faster
Explain Cache hit & Cache miss?
When a piece of data is required, the cache is checked first. If:
- The item is found, there is a cache hit & the data is retrieved.
-The data is not found, there is a cache miss and the item must be obtained form the main memory. The complete block containing the word is then brought into the cache to avoid a miss next time
How can you limit the CPU workload of controlling I/Os?
Use peripheral processor to offload some of the tasks
What does the data exchange of peripheral processors look like?
- Periph <-> CPU:
CPU reads/writes all data to peripheral processor, which handles the I/Os - Periph <-> Memory
Peripheral processor may directly access memory and load/store data directly - Periph <-> Periph
Peripheral processor may directly communicate with other peripherals over the system bus
Computation of timer prescalers?
- Determine input clock frequency that is fed into the timer
- Define the desired frequency
- Calculate prescaler value: input clock frequency/desired frequency
- Choose closest available prescaler setting e.g. 1,2,4,8,32,54,256 etc. basically the number of bits)
What is polling? Drawback?
Constant checking for the occurrence of an event
Time-consuming and requires change in focus from the foreground task
What are interrupts used for?
Interrupts handle asynchronous events (e.g. timer ticking, keyboard/button press)
They are triggered by hardware or by specific software conditions
What is an interrupt and how does it differ from polling?
Using interrupts means you do not repeatedly check for the occurrence of an event.
Instead, when the event happens, we allow it to disrupt the program and force something to happen.
Analogy: Phone call. You are forced to decide to ignore it, answer it, or decline
What happens after an interrupt is triggered?
The CPU stops executing the current code and jumps to an ‘Interrupt Service Routine’ (ISR)
Interrupts do not return anything and variables can’t be passed to them
What does an interrupt consist of?
- Interrupt event and source
- The interrupt handler
- The interrupt service routine (ISR) is called by the interrupt handler
Once ISR is executed, MCU jumps back into the code
What is masking in the context of interrupts?
If you have multiple interrupt lines grouped together, you can specify which ones can generate an interrupt
What are the options when you have multiple interrupts?
2 ideas:
- Interrupt nesting: Interrupt the first interrupt to execute the second one
- Tail-chaining: Finish processing the first interrupt before beginning on the second one
What are the benefits of low power modes?
Increased battery life (mobile applications)
lowered power consumption (stationary applications)
Compare power optimization and clock frequency?
In low power mode:
- Very slow clock frequency (100kHz)
- Very energy efficient
Normal running mode:
- Full speed (80MHz)
- Not very energy efficient
Name some low power modes?
- Shut down
- Stop
- Standby
- Sleep
- Low power sleep
Features of sleep & low power sleep modes?
- CPU is stopped
- Peripherals and DMA can still work
- Can wake up CPU with an interrupt
Until what stop mode can GPIOs be used?
Until stop 2 mode
4 components of the task interaction model
- The information (data or signals being moved)
- The place (from which the info is moved from and to)
- Control and synchronization
- Transport mechanism (physical means by which it is moved)
3 types of direction of flow
- Simplex: information being sent in one direction only
- Half Duplex: Information being sent in both directions but only one at a time
- Duplex: Information can be sent in both directions simultaneously
4 ways to relay a message
- Unicast (point-to-point)
- Broadcast (message sends same info to all components e.g. ‘Reset’)
- Multicast (Single sender transmits to reduced subset of receivers)
- Anycast (Message to one recipient from a group of messengers)
Types of transport mechanisms
- Ring
- Star
- Bus
- Line
Interconnect architecture of a Star
- Master-slave arrangement
- Slave-to-slave communication must go through the master (middle node)
- Master initiates and directs everything in the system
- Master is single point of failure (communication continues if slave fails, but not master)
- Example: USB (Star-bus)
Interconnect Architecture: Ring (Daisy Chain)
- No bus master (all considered equal)
- Each device has unique address
- Message arrives, if addressed to me I read it. If not, I pass it on to the next device
- In theory only needs 1 receiver, and 1 transmitter
Interconnect Architecture: Parallel Bus
- Each device connected on a single cable (line)
- May or may not be a bus master
- All have unique addresses
Which architecture has the highest bandwidth?
Star