What happens when a microcontroller boots?
1) reset signal is issued: starts the system clock
2) fetches reset vector
3) Startup code runs
4) Stack initialised
5) global/static variables initialised
6) main function is called
What is fetching the reset vector?
This is when the processor loads the address of the first instruction of the boot code
Why is clock frequency important?
Clock frequency determines how fast your program is executed
- but it uses higher power consumption
Purpose of an external crystal?
Provides accurate clock signal to a microcontroller
And provides accurate timing for
- communication
- timers
- clocks
SPI vs I2C
**SPI: **
- full duplex: transmit and receive data at the same time
- 4+ wires
- faster
- no addressing: does not have a mechanism to uniquely identify different devices
**I2C: **
- half duplex: can transmit and receive data but not at the same time
- 2 wires
- slower
- Addressing
What is UART used for?
Serial communication
- debug logs
- view sensor data
What is DMA?
DMA: direct memory access
- allows peripherals to transfer data without CPU involvement
Memory-mapped I/O
Way of interacting with hardware by writing to or reading from predefined addresses where those addresses control the peripheral