1 Introduction
2 ------------
3
4 This example demonstrates the generation of an analogue VGA signal from a
5 PIC32 microcontroller using general output pins. Instead of using DMA, which
6 was the focus of the VGAPIC32 project and is a central feature of the
7 approaches demonstrated by other examples (vga, vga-dual, vga-pmp, vga-timer),
8 here the CPU is given the task of transferring pixel data to the output pins.
9
10 Instead of a timer interrupt condition initiating DMA transfers, the interrupt
11 is handled and a routine invoked to issue the necessary load and store
12 instructions in a loop. Otherwise, the use of the timer to generate sync
13 pulses is as in the other examples and the general display state machine is
14 largely the same.
15
16 The resulting picture is more pleasing than that produced by most of the DMA
17 examples in that the display pixels have consistent widths. Moreover, the
18 pixels are also narrower than those produced by the vga-timer example. It is
19 possible to generate a display with something approaching 200 pixels
20 horizontally, with 160 pixels being demonstrated.
21
22 However, the CPU now spends a lot of time occupied in an interrupt request
23 handler generating pixels. This seems less elegant than using DMA, but in
24 practice, the CPU may be effectively stalled where DMA transfers dominate
25 access to the RAM. Even if, in such situations, the CPU may be able to access
26 flash memory to load instructions, programs typically end up accessing RAM at
27 some point, and this would effectively limit the concurrency within the
28 system. Certainly, this approach seems to result in slower programs than the
29 plain DMA-based approach.
30
31 One potential advantage of this approach is in the flexibility that might be
32 achieved by manipulating the pixel data. With DMA, data is transferred as it
33 is found and is generally not transformed (although there are some features in
34 the PIC32 DMA controller for certain kinds of data), whereas we might envisage
35 supporting display modes employing fewer bits for the output signal, reducing
36 the number of colours but also the size of the framebuffer.
37
38 Hardware Details
39 ================
40
41 The pin usage of this solution is documented below.
42
43 PIC32MX270F256B-50I/SP Pin Assignments
44 --------------------------------------
45
46 MCLR# 1 \/ 28
47 HSYNC/OC1/RA0 2 27
48 VSYNC/OC2/RA1 3 26 RB15/U1TX
49 D0/RB0 4 25 RB14
50 D1/RB1 5 24 RB13/U1RX
51 D2/RB2 6 23
52 D3/RB3 7 22 RB11/PGEC2
53 8 21 RB10/PGEC3
54 RA2 9 20
55 RA3 10 19
56 D4/RB4 11 18 RB9
57 12 17 RB8
58 13 16 RB7/D7
59 D5/RB5 14 15
60
61 Note that RB6 is not available on pin 15 on this device (it is needed for VBUS
62 unlike the MX170 variant).
63
64 UART Connections
65 ----------------
66
67 UART1 is exposed by the RB13 and RB15 pins.
68
69 Data Signal Routing
70 -------------------
71
72 For one bit of intensity, two bits per colour channel:
73
74 D7 -> 2200R -> I
75
76 I -> diode -> R
77 I -> diode -> G
78 I -> diode -> B
79
80 D6 (not connected)
81
82 D5 -> 470R -> R
83 D4 -> 1000R -> R
84 D3 -> 470R -> G
85 D2 -> 1000R -> G
86 D1 -> 470R -> B
87 D0 -> 1000R -> B
88
89 HSYNC -> HS
90 VSYNC -> VS
91
92 Output Socket Pinout
93 --------------------
94
95 5 (GND) 4 (NC) 3 (B) 2 (G) 1 (R)
96
97 10 (GND) 9 (NC) 8 (GND) 7 (GND) 6 (GND)
98
99 15 (NC) 14 (VS) 13 (HS) 12 (NC) 11 (NC)
100
101 Output Cable Pinout
102 -------------------
103
104 1 (R) 2 (G) 3 (B) 4 (NC) 5 (GND)
105
106 6 (GND) 7 (GND) 8 (GND) 9 (NC) 10 (GND)
107
108 11 (NC) 12 (NC) 13 (HS) 14 (VS) 15 (NC)
109
110 References
111 ----------
112
113 https://en.wikipedia.org/wiki/VGA_connector
114
115 http://papilio.cc/index.php?n=Papilio.VGAWing
116
117 http://lucidscience.com/pro-vga%20video%20generator-2.aspx
118
119 https://sites.google.com/site/h2obsession/CBM/C128/rgbi-to-vga