Skip to content

Fix issues #21 to #27 for the next release - #28

Merged
begeistert merged 7 commits into
mainfrom
fix/release-issues-21-27
Oct 8, 2026
Merged

begeistert merged 7 commits into
mainfrom
fix/release-issues-21-27

Conversation

@begeistert

Copy link
Copy Markdown
Collaborator

Resolves the open emulator issues ahead of the next release. The main consumer in mind is iCircuit (CircuitMirror), which runs Uno and Mega sketches on the core through AvrRunner.

Core

TestKit / C ABI / Python

Verification

  • Avr8Sharp.Tests: 583/583 (was 548)
  • TestKit.Samples: 45/45 (was 21)
  • Python bindings: 28/28 against a fresh Native AOT build (osx-arm64)
  • CircuitMirror's Arduino and DataBus tests: 101/101 against this core packed locally (includes SSD1306 over I2C)

#23 was already fixed on main in f2a1178.

Closes #21, closes #22, closes #24, closes #25, closes #26, closes #27.

RCALL added its signed offset as an unsigned 16-bit value, so on an
ATmega2560 every backward rcall landed 0x10000 words too high. The 328P
hid it because its flash length divides 0x10000. RET/RETI subtracted 1
from the low 16 bits before OR-ing in the high byte, so a return address
whose low word is zero lost its high byte. Both now do the arithmetic on
the full address.
An input pin whose PORT bit is set reads 1 while nothing drives it. A pin
counts as driven from the first SetPinValue until the new ReleasePin, so
an embedder that injects every input on every step sees no change.
Enabling the pull-up on a floating pin now raises the pin-change edge the
chip does. Gpio.PortWrite and Gpio.PinToggle asserted a floating pull-up
reading 0 and now expect the silicon value.
…24)

START and STOP take one SCL period, an address or data byte nine, at
16 + 2 * TWBR * prescaler CPU cycles per period, before TWINT is raised.
The time counts from the dispatch to the ITwiEventHandler, so a handler
that completes later adds no extra delay. EmulateBusTiming = false
restores the next-cycle completion.
REFS1:0 is 00 AREF, 01 AVCC, 10 reserved, 11 internal 1.1 V (table 28-3).
The table was the ATmega8's, so analogReference(INTERNAL) converted
against 2.56 V. Also adds Atmega2560AdcConfig (16 channels, MUX5 selects
ADC8-15); MUX5 is ignored on 8-channel configs.
…put (#25)

The predicate ran on every instruction against a string rebuilt from all
the bytes received so far, so long runs that print were quadratic in the
output. SerialProbe.Text is cached until the next byte, and the text
predicates run only when the probe's version changes. The core was
checked across the 2^31 and 2^32 cycle boundaries and was not the cause;
CycleBoundaryTests pins clock events and Timer0 there.
…ode (#26, #27)

ArduinoUnoSimulation and ArduinoMegaSimulation mount SPI, TWI, ADC and the
watchdog. The SPI and TWI device stubs move from the native layer into
TestKit.Core (Avr8Sharp.TestKit.Probes) so the boards and the C ABI share
one wiring. AvrWatchdog owns MCUSR: PORF on power-on, EXTRF on any other
CPU reset, WDRF on a watchdog reset, and a flag clears only on a written
zero.

UnmountedAccess (Ignore by default, Warn, Throw) reports a read or write
of PINx/DDRx/PORTx of a port that was never added; its hooks are only
installed when the mode leaves Ignore.

C ABI: a8s_set_strict, a8s_read_warnings, a8s_gpio_release_pin.
Python: Simulation.with_strict, Simulation.warnings, Port.release, and
adc/spi/twi on ArduinoMega.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying avr8sharp-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9625733
Status: ✅  Deploy successful!
Preview URL: https://f5182228.avr8sharp-docs.pages.dev
Branch Preview URL: https://fix-release-issues-21-27.avr8sharp-docs.pages.dev

View logs

@begeistert
begeistert merged commit d42a2da into main Oct 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment