ubb-vga: 640x480 without FIFO jitter; less noise

Werner Almesberger werner at almesberger.net
Tue May 3 17:27:43 EDT 2011


David Kuehling wrote:
> I wonder whether having a high-priority timer interrupt would help here?

Oh, an interrupt handler would be waaaaaay too slow for this. I'm
aiming for +/-5 ns accuracy or better here. For comparison, the evil
noise I reduced recently was about +/- 50 ns.

At the moment, the timing works basically like this:

	start_timer;
	while (timer != deadline);
	/* fine-tuning follows */

The timer runs at 112 MHz (PCLK), but I can access it only at about
13 MHz (APB is slow). So this is the limit of the accuracy of this
timing loop.

I think a further improvement may be possible by using interrupts.
Not to run an interrupt handler, but to release the CPU from a WAIT
instruction. Alas, WAIT is privileged, so the display loop will have
to move into the kernel for this.

> Already thought about hooking into interrupts on the NanoNote.  Might
> work like in the MS-DOS days.  Just read out the current value of the
> IRQ in the vector table, replace it by our own IRQ routine, and make our
> IRQ routine (selectively?) tail-jump to the original IRQ.

Heh, that's dirty. Naw, at some point you just have to bite the
bullet and do it in the kernel. The VGA output is already pushing
things extremely far.

Tweaking interrupt handling in the kernel may be necessary to
control the latency, though. If we want to allow other things to run
while displaying VGA images, we'll need to set up an interrupt after
the MMC transfer has been started, let the kernel do other stuff,
then take the interrupt before the end of the image line, busy-wait
until we're exactly at the end, and then proceed with the next line.

The total time between starting the pixel data and the end of the
line would be between 15-25 us. From this, we have to subtract the
worst-case latency. This worst-case latency is mainly determined by
the longest time during which interrupts are disabled.

We can probably afford to miss the deadline from time to time, so if
there's a place that disabled interrupts for a long time, that's
okay as long as this code doesn't run too often.

- Werner




More information about the discussion mailing list


interactive