CommonPIC32

docs/wiki/Examples--vga-cpu

150:82a63936a118
2019-06-11 Paul Boddie Added initial library documentation.
     1 = VGA Output Example (CPU-Driven Transfers) =     2      3 This example demonstrates the generation of an analogue [[VGA Signal Output|     4 VGA]] signal from a PIC32 microcontroller using general output pins. Instead     5 of using DMA, which was the focus of the VGAPIC32 project and is a central     6 feature of the approaches demonstrated by other examples ([[../vga|vga]],     7 [[../vga-dual|vga-dual]], [[../vga-pmp|vga-pmp]], [[../vga-timer|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|vga-timer]]    19 example. It is possible to generate a display with something approaching 200    20 pixels 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 The pin usage of this solution is documented below.    41     42 === PIC32MX270F256B-50I/SP Pin Assignments ===    43     44 {{{    45 MCLR#          1  \/  28    46 HSYNC/OC1/RA0  2      27    47 VSYNC/OC2/RA1  3      26 RB15/U1TX    48        D0/RB0  4      25 RB14    49        D1/RB1  5      24 RB13/U1RX    50        D2/RB2  6      23    51        D3/RB3  7      22 RB11/PGEC2    52                8      21 RB10/PGEC3    53           RA2  9      20    54           RA3 10      19    55        D4/RB4 11      18 RB9    56               12      17 RB8    57               13      16 RB7/D7    58        D5/RB5 14      15    59 }}}    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 UART1 is exposed by the RB13 and RB15 pins.    67     68 === Data Signal Routing ===    69     70 For one bit of intensity, two bits per colour channel:    71     72 {{{    73 D7 -> 2200R -> I    74     75 I -> diode -> R    76 I -> diode -> G    77 I -> diode -> B    78     79 D6 (not connected)    80     81 D5 -> 470R -> R    82 D4 -> 1000R -> R    83 D3 -> 470R -> G    84 D2 -> 1000R -> G    85 D1 -> 470R -> B    86 D0 -> 1000R -> B    87     88 HSYNC -> HS    89 VSYNC -> VS    90 }}}