Skip to the content ForoHackers
Log inJoin

Microcontrollers: start here

Microcontrollers
#2943 · · Quote · 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

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply