SCOPE Solution
SAW DOWN
SCOPE ACT 1

Prerequisites
Unlocks
sc_a1_07_sawdown locked
Par power1055
Par lines6
Par chips1
Objective
A falling sawtooth 255..0 then a snap back to 255.
Board Data
- Window: 264
- Pins: p0 OUT
- Channels: p0 ANALOG label=CH1_p0_DAC
- Peripherals: DAC data=p0 label=DAC_on_p0
Firmware Solution
; SAW DOWN reference: falling sawtooth 255,254,...,1,0 then wrap (snap) to 255 and
; fall again. r0 is the level; dec wraps mod 256, so the snap is automatic. r0 is set
; to 255 once, before the loop, so the picture opens at the top.
mov r0, 255
loop:
out p0, r0 ; draw the current level
slp 1 ; one tick per level
dec r0 ; next level (wraps 0 -> 255)
jmp loop
Board Definition
# SAW DOWN. ACT 1, analog. The mirror of RAMP: step a register DOWN through the DAC
# one level per tick, so the picture falls instead of climbs. dec wraps 0 back to 255,
# so the snap to the top is automatic. The window runs past 256 so the snap at the
# wrap is visible. Reference is sc_a1_07_sawdown.asm.
# TITLE SAW DOWN
# OBJECTIVE A falling sawtooth 255..0 then a snap back to 255.
ID sc_a1_07_sawdown
WINDOW 264
DIR p0 OUT
PERIPH DAC data=p0 label=DAC_on_p0
CHAN p0 ANALOG label=CH1_p0_DAC
PAR power=1055 lines=6 chips=1