Skip to content

atmega: make blinky example visible on real hardware - #1063

Open
matpala wants to merge 2 commits into
ZigEmbeddedGroup:mainfrom
matpala:atmega/fix-blinky-delay
Open

matpala wants to merge 2 commits into
ZigEmbeddedGroup:mainfrom
matpala:atmega/fix-blinky-delay

Conversation

@matpala

@matpala matpala commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

On real hardware (ATmega328P @ 16 MHz, ReleaseSmall) the blinky example toggled the LED every ~9 ms, so it looked solidly on.

A single busy_sleep(20_000) compiles to a 7-cycle loop (cpi/cpc/breq/adiw/rjmp), i.e. ~140k cycles ≈ 8.75 ms per toggle. This repeats it 50 times, giving ~437 ms per toggle (~1.1 Hz blink).

Tested on an Emakefun RF-Nano V3.0 (Arduino Nano compatible, ATmega328P @ 16 MHz) with the arduino-nano_blinky target: ~34 blinks in 30 s, matching the computed value. The arduino-uno_blinky target uses the same chip and clock, so the same timing applies.

Comment thread examples/microchip/atmega/src/blinky.zig Outdated
A single busy_sleep(20_000) compiles to a 7-cycle loop in ReleaseSmall,
so each toggle took ~8.75 ms at 16 MHz and the LED looked solidly on.
Repeating it 50 times gives ~437 ms per toggle (~1.1 Hz blink).

Tested on an Emakefun RF-Nano V3.0 (ATmega328P @ 16 MHz): ~34 blinks
in 30 s, matching the computed value.
@matpala
matpala force-pushed the atmega/fix-blinky-delay branch from 495ea6e to aabf5bc Compare October 4, 2026 16:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants