Syscall 2: Firmware, home

BenchChapter 4: Stars and hubs

B17SHARK FIN

The task

P0 charges C1 through R1. The capacitor fills and drains slowly,

so each edge on P0 bends into a curve on CH1.

P1 ticks every 20 cycles. Hold P0 high for three ticks, then low for one, and repeat.

The board

The chip of SHARK FINChip u1 with 2 ports: P0 digital out, reaching R1, C1, CH1; P1 timer 20 cycles.u1CHIP SC-2P0DIGITAL OUTR1, C1, CH1P1TIMER 20 CYCLES
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes.
Resistors
R1 2.2 kΩ
Capacitors
C1 1 µF
Probes
CH1

Key idea

A square wave through R1 and C1 looks like a row of fins on the scope.

Hints

Each hint goes a step further than the one before. Open them one at a time.

Hint 1Show

Each extra sleep at one level adds a tick at that level.

Hint 2Show

Sleep, write 1, sleep three times, write 0.

Solution

Reveal the Full SolutionThe complete program for SHARK FIN. Open it only when you want the answer.

The reference program

The game's own solution. It passes every test and scores exactly par on every benchmark.

Three ticks charging, one tick draining.

u1SC-2 standard

IN P1
MOV A, 1
OUT P0
IN P1
IN P1
IN P1
MOV A, 0
OUT P0
CYCLES
30
at par
ENERGY
60
at par
NODES
1
at par
INSTRUCTIONS
8
at par