<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Avr on TurboVision</title>
    <link>https://turbovision.in6-addr.net/tags/avr/</link>
    <description>Recent content in Avr on TurboVision</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Tue, 21 Apr 2026 14:06:12 +0000</lastBuildDate>
    <atom:link href="https://turbovision.in6-addr.net/tags/avr/index.xml" rel="self" type="application/rss&#43;xml" />
    
    
    
    <item>
      <title>AVR Bare-Metal Blinking</title>
      <link>https://turbovision.in6-addr.net/electronics/microcontrollers/avr-bare-metal/</link>
      <pubDate>Wed, 20 Aug 2025 00:00:00 +0000</pubDate>
      <lastBuildDate>Sun, 22 Feb 2026 15:48:59 +0100</lastBuildDate>
      <guid>https://turbovision.in6-addr.net/electronics/microcontrollers/avr-bare-metal/</guid>
      <description>&lt;p&gt;No Arduino libraries. No HAL. Just registers.&lt;/p&gt;
&lt;p&gt;An ATmega328P has DDRB, PORTB, and a 16-bit timer. We configure Timer1
in CTC mode with a 1 Hz compare match, toggle PB5 (the onboard LED pin)
in the ISR, and end up with a binary that fits in 176 bytes. The Makefile
uses &lt;code&gt;avr-gcc&lt;/code&gt; and &lt;code&gt;avrdude&lt;/code&gt; directly — no IDE required.&lt;/p&gt;
&lt;p&gt;This exercise looks trivial, but it trains the exact muscle many developers
skip: understanding cause and effect between register writes and hardware
behavior. You do not &amp;ldquo;ask an API&amp;rdquo; to blink. You define direction bits, timer
prescalers, compare values, and interrupt masks yourself.&lt;/p&gt;
&lt;h2 id=&#34;minimal-mental-model&#34;&gt;Minimal mental model&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;DDRB&lt;/code&gt; configures PB5 as output.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;TCCR1A/TCCR1B&lt;/code&gt; define timer mode and prescaler.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;OCR1A&lt;/code&gt; sets compare threshold.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;TIMSK1&lt;/code&gt; enables compare interrupt.&lt;/li&gt;
&lt;li&gt;ISR toggles &lt;code&gt;PORTB&lt;/code&gt; bit for the LED.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When this chain is explicit, debugging gets faster. If timing is wrong, you
inspect clock and prescaler. If the LED is dark, verify direction and pin.
Each symptom maps to a small set of causes.&lt;/p&gt;
&lt;h2 id=&#34;why-still-do-this-in-2026&#34;&gt;Why still do this in 2026&lt;/h2&gt;
&lt;p&gt;Bare-metal AVR is still a great teaching platform because feedback is fast
and tooling is mature. You can compile, flash, and verify behavior in a few
seconds, then iterate. Even if your production target is different, this
discipline transfers directly to RISC-V, ARM, and RTOS-based projects.&lt;/p&gt;
&lt;p&gt;Related reading:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://turbovision.in6-addr.net/electronics/microcontrollers/riscv-on-ch32v003/&#34;&gt;RISC-V on a 10-Cent Chip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://turbovision.in6-addr.net/musings/why-constraints-matter/&#34;&gt;Why Constraints Matter&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
  </channel>
</rss>
