Skip to content

Commit 7a4bc1b

Browse files
committed
Tweak the timing back to spec.
1 parent 6468f32 commit 7a4bc1b

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/vga/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ static TIMING_BUFFER: TimingBuffer = TimingBuffer {
196196
make_timing(16 * 5, true, false, false),
197197
// Sync pulse (as per the spec)
198198
make_timing(96 * 5, false, false, false),
199-
// Back porch (shortened by two pixels because the
200-
// video starts two pixels late)
201-
make_timing(48 * 5, true, false, false),
202-
// Visible portion. It also triggers the IRQ to start pixels moving.
203-
make_timing(640 * 5, true, false, true),
199+
// Back porch. Adjusted by a few clocks to account for interrupt +
200+
// PIO SM start latency.
201+
make_timing((48 * 5) - 5, true, false, false),
202+
// Visible portion. It also triggers the IRQ to start pixels
203+
// moving. Adjusted to compensate for changes made to previous
204+
// period to ensure scan-line remains at correct length.
205+
make_timing((640 * 5) + 5, true, false, true),
204206
],
205207
},
206208
vblank_porch_buffer: ScanlineTimingBuffer {
@@ -493,9 +495,9 @@ pub fn init(pio: super::pac::PIO0, dma: super::pac::DMA, resets: &mut super::pac
493495
// | 1 | out pins, 2 | wait 1 irq 0 |
494496
// | 2 | out x, 14 | wait 1 irq 0 |
495497
// | 3 | out exec, 16 | wait 1 irq 0 |
496-
// | 4 | <irq> | wait 1 irq 0 |
498+
// | 4 | <exec irq> | wait 1 irq 0 |
497499
// | 5 | jmp x-- | wait 1 irq 0 |
498-
// | 6 | | set x, 31 |
500+
// | 6 | | out x, 32 |
499501
// | 7 | | out pins, 16 [4] |
500502
// | 8 | | .. |
501503
// | 9 | | .. |
@@ -505,7 +507,7 @@ pub fn init(pio: super::pac::PIO0, dma: super::pac::DMA, resets: &mut super::pac
505507
// | 13 | | .. |
506508
// | 14 | | .. |
507509
// | 15 | | .. |
508-
// | 16 | | jump x-- loop1 |
510+
// | 16 | | jump x-- |
509511
//
510512
// Note: Credit to
511513
// https://gregchadwick.co.uk/blog/playing-with-the-pico-pt5/ who had a

0 commit comments

Comments
 (0)