Node 517

This node generates horizontal sync signal. It also passes clock signal to node 617.

Source code

usb node 617 node 516 node 517
517 hsync
ticks 00 n for @ ! unext ;
-ticks 02 n for @ - ! unext ;
sync 05 5 ticks !b 30 ticks !b 18 ticks ;
blanks 0D n for sync 199 ticks next ;
lines 13 n for sync 199 -ticks next ;
go 19 44 blanks 479 lines go ; 1E

init io b! 1C5 r--u a! 20000 30000 over over
over over over over over over !b go ; 28

4 d 9 r 2 u ether


Count n+1 clock pulses while sending pulses (zeros) to 617.
Count n+1 clock pulses while sending inverted pulses (-1) to 617.
Generate back porch for 6 clock ticks, a negative horizontal sync pulse lasting 31 ticks, and front porch for 19 ticks.
Generate blank line starting with sync pulse and lasting 200 ticks.
Generate image line starting with sync pulse and lasting 200 ticks.
Generate 45 blank lines and 480 image lines repeatedly.
Set registers A and B, fill stack with alternating values 20000 and 30000, set pin 517.17 high, and jump to go.


Generation of HSYNC signal is based on 8 Mpulses/s clock rate coming from node 516. It is received as a stream of zeros. It is passed to node 617 unchanged during horizontal and vertical blanking by word ticks, and is inverted by word ‑ticks to ‑1 during active video time. One scan line is defined as 256 clock pulses so its duration is exactly 32 µs. It is slightly longer than what corresponds to standard VGA so the frame refresh rate is ~59.5 Hz.

This node generates a negative HSYNC pulse on its GPIO pin at the beginning of each scan line, with duration of 3.88 µs, i.e. 31 clock pulses. The front porch is set to 6 clock pulses (0.75 µs), and back porch to 19 clock pulses (2.38 µs). It is possible to change slightly width of the pulse and length of both porches in order to adjust timing to a particular monitor but the total number of blanking clock pulses must be kept the same, i.e. 56 clock pulses.