| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| hardware | 2010-09-06 | ||
| 80column-readme.rtf | 2010-09-06 | 7.3 kB | |
| 80columnvideo.JPG | 2010-09-06 | 157.9 kB | |
| 80columnvideo.c | 2010-09-06 | 39.2 kB | |
| Totals: 4 Items | 204.4 kB | 4 |
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset2 Symbol;}}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 Minimal Hardware Required\par
\par
\pard{\pntext\f1\'B7\tab}{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\fi-360\li720\sa200\sl276\slmult1 Run the PIC at 3.3 volts.\par
{\pntext\f1\'B7\tab}Use a 14.31818 mHz crystal (4x NTSC colorburst)\par
{\pntext\f1\'B7\tab}Connect pin C2 to a video output connector via a 680 ohm resistor. \par
{\pntext\f1\'B7\tab}Connect pin C7 to a video output connector via a 330 ohm resistor.\par
{\pntext\f1\'B7\tab}Connect the video output connector to the composite input of a TV or monitor. Make sure you have both signal and ground connections.\par
\pard\sa200\sl276\slmult1\par
\par
\par
Theory of Operation\par
\par
R2 and R3 form a primitive 2-bit DAC. The television is an important part of the DAC because it provides 75 ohm termination. If you are measuring the voltage output without a TV attached be sure to add a 75 ohm resistor between video output and ground. The resistor values were chosen to get as close to the standard video levels as possible: 0.0 volts (sync), 0.3 volts (black), and 1.0 volts (white). If you substitute a 5.0 volt PIC you will need to change the resistor values. \par
\par
Pin C2 is the sync pin.When it's high the video signal is ~0.3 volts (black). When it's low the video signal is ~0 volts (sync). Pin C7 is output from the video shift register. When the sync pin is high a high on C7 produces ~1.0 volt which is our white level. When it's low the output is ~0.3 volts which is our black level. It is possible to get gray scale pixels by raising C7 and lowering C2 but we do not use this combination. \par
\par
Timer2 is programmed to trigger an interrupt at the beginning of each scan line. With a 14.31818 mHz crystal it fires every 908 instruction clocks (it would be perfect if it fired every 909.09 clocks).\par
The PIC's EUSART is used in master synchronous transmit mode as a high speed video shift register. The baud rate generator is set to zero which give us one pixel per instruction cycle (14.31818 megapixels/second). A tight loop written in assembly language loads the character code from RAM, converts it to a bitmap via a second lookup from the character generator (in ROM), and writes the byte into the transmit register. Each pass through the loop takes 16 instruction cycles and outputs two characters. \par
Because the user program only runs when the interrupt handler is not busy we try to spend as little time inside the interrupt as possible. Upon entering the ISR we start our 4 microsecond sync pulse before we save the CPU registers. Once the registers are saved we turn the sync off. Right now we are not doing any useful work during the backporch (8 microseconds per line) so this would be a good time to do something like service a PS/2 keyboard port.\par
I originally tried to implement 40 column mode by using a lower baud rate. I found that the EUSART would leave a one pixel gap between characters when I did that. As a workaround I created a lookup table which translates 8-bit wide font data into double pixel 16-bit wide output. This consumes 512 bytes of precious RAM. Another solution would be to use a 27mHz (or 28.636)crystal in HS mode (no PLL) This would give a pixel clock of 6.75 mHz (or 7.159). This would save the 512 bytes wasted on lookup table RAM and allow you to use almost any PIC without overclocking. The downside is that user programs would only have half as many CPU cycles available. Maybe I'll post a 40 column version of the code for a 27mHz crystal. \par
I did try to use the MSSP (SPI & I\'b2C module) instead of the EUSART but it is not capable of continuous transmission and it left a gap between characters. If you don't "mind the gap" you could use the MSSP and free up the EUSART for communications. \par
Notes\par
\pard{\pntext\f0 1.\tab}{\*\pn\pnlvlbody\pnf0\pnindent0\pnstart1\pndec{\pntxta.}}
\fi-360\li720\sa200\sl276\slmult1 The PIC18F26K20 is rated at 64mHz. With a 4X PLL we run it at 57.3 mHz which (div 4) gives an instruction cycle of 69.84 nanoseconds. You might be able to overclock a slower PIC if you don't have an 18F26K20 handy. \par
{\pntext\f0 2.\tab}Only the industrial version of the 18F26K20 is rated at 64mHz. The extended temperature version is only rated at 48 mHz. \par
{\pntext\f0 3.\tab}Change to #define CRYSTAL13 if you have a 13.5 mHz crystal. This gives you CCIR-601 square pixels. \par
{\pntext\f0 4.\tab}If all you have is a 16mHz crystal you can #define CRYSTAL16. You will have a large overscan area if you run at 16 mHz. It is also possible to use the PIC's internal 16mhz oscillator instead of a crystal but the display will be wavy. \par
{\pntext\f0 5.\tab}You need a PIC with a full ~3800 bytes of RAM because an 80 column video display takes 2000 bytes. \par
{\pntext\f0 6.\tab}For better results use the luma channel of an S-video connection. \par
{\pntext\f0 7.\tab}For best results use the component video "Y" input on your HDTV (the green plug).\par
{\pntext\f0 8.\tab}Uncomment the line #define COLUMN40 if you only want a 40 column video display. 40 column mode still takes more than 1536 bytes (it won't fit an 18F25K20) because it uses a 512 byte lookup table to double stretch the pixels. \par
{\pntext\f0 9.\tab}All the video is generated from inside a global interrupt handler leaving the processor free to run your own code without polling or timing restrictions. The TIMER2 interrupt runs at 15.750 kHz which is the horizontal scan rate of NTSC video. \par
{\pntext\f0 10.\tab}The code uses the EUSART in master synchronous mode as a video shift register. This means no UART is available for communication. If you need a serial port you could try get get your hands on a PIC 18F26J22 which has a second EUSART.\par
{\pntext\f0 11.\tab}The PIC 18F26K20 has hardware slew rate control of its output pins. Changing the slew rate affects the quality of the video. The best setting depends on the display device you are using. A high slew rate works well on an HDTV. A lower slew rate works well on an analog CRT television.\par
{\pntext\f0 12.\tab}This was compiled using version 4.112 of the CCS compiler. It will not work correctly on version 4.095, so make sure you have the latest version of the compiler.\par
\pard\sa200\sl276\slmult1 The ROM font is 8X8 pixel ASCII. The upper 128 characters are inverse video. There are some special symbols in the lower 32 characters. I used the freeware CosmicVoid CFE_64 Font Editor to create the custom font and a quick and dirty program I wrote with Microsoft Visual C++ Express to convert the font file into interleaved ROM data. \par
This project was inspired in part by Rickard Gun\'e9e's PIC video PONG and Tetris and partly by Don Lancaster's 1978 classic The Cheap Video Cookbook.\par
The next step is to finish support for a PS/2 keyboard interface. Once that's done and the PIC18F26K22 becomes available (later this quarter) we can use the second EUSART as standard serial port, creating a full fledged ANSI video terminal using only a single chip. Stay tuned!\par
If you have questions or comments drop me a line: chicago@quackenbush.com\par
}