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