Skip to the content ForoHackers
Log inJoin

Microcontrollers: start here

Microcontrollers
#437 · Ophuscado · · Report

A microcontroller is a whole small computer on one chip: a CPU core, flash for the program, RAM, and peripherals wired to pins. It runs one program from power-on to power-off, usually without an operating system, and it talks to the world through voltages, timers and buses.

Key concepts

  • Memory map: peripherals are addresses. Writing a register turns a pin on, starts a timer or sends a byte.
  • Interrupts: hardware stops your code to run a handler, then returns. Keep handlers short; share data with care.
  • Clocks and power: the clock tree sets the speed of everything; sleep modes and wake sources decide battery life.
  • Peripherals: GPIO, timers and PWM, ADC and DAC, UART, SPI, I2C, USB, DMA.
  • Toolchain and debug: cross-compiler, linker script, startup code, a flasher and a SWD or JTAG probe.

Vocabulary

  • HAL: hardware abstraction layer, the vendor's or your own wrapper over registers.
  • Bare metal: code that runs with no operating system under it.
  • Watchdog: a timer that resets the chip unless the program keeps feeding it.
  • Datasheet and reference manual: the first says what the chip is; the second, how every register behaves.

What to study, in order

  1. C with pointers, bitwise operators and volatile; what a linker script places where.
  2. Blink an LED from registers alone, then with the vendor HAL; compare the two.
  3. Timers, interrupts and a UART console; then SPI and I2C against a real sensor.
  4. DMA, low-power modes and a watchdog; measure current, not just time.
  5. A logic analyser and a debugger on every bug, before adding prints.

Related tags

#firmware #rtos #embedded-linux #bootloaders

Log in or join to reply.