====== VGA-terminal with PIC18 ====== This article tells how to output data to VGA monitor using controller PIC18. This controller is not quite well for tasks like this, but this example shows that it isn't impossible. This program was written in 2004, and it is introduced here just for describe principles of [[:osa:articles:vga_game|"VGA game with PIC18"]] project. Source code is here: {{:osa:articles:terminal.rar|}} Specification: {|class = "fpl" |- |**Text screen resolution** |30x30 chars |- |**Graphics resolution** |240x480 pixels |- |**Char size** |8x16 pixels |- |**Colors** |15 |- |**Cursor emulating** |Yes. |- |**Char set** |English, Russian |- |**Interface** |SPI, up to 250 kbits per second |- |**** | |} There are two limitations: - background color is always black; - one symbol can be drown with one colour only. Here is demo mode generated screen. (Ptogram was written in 2004, and demo-screen function was added just now for demonstration purpose): {{:osa:articles:vga_trm_demo_screen.jpg?350|}}{{:osa:articles:vga_trm_large_plan.jpg?350|}} ===== VGA colntrol ===== ==== Some theory ==== VGA monitor is controlled by 5 wires: * 2 digital wires (horisontal and vertical syncho pulses); * 3 analog wires (reg, green and blue levels). Syncronization wires used to tell to monitor when frame started and how march frames per second. Analog wires used to specify color of every pixel on the screen. The higher voltage on wire brings the brighter color. By combinating different voltage levels on three RGB wires we can gen different colors (e.g. when generating simmilar levels for red and green wires and zero level for blue wire, we will get yellow color). The picture on the sreen is drawed line by line from the top to the bottom. Each line drown left to right. When line fully drown, horisontal synchronization pulse will be generated (HSYNC) to tell to monitor that next part of information should be drown at next line. When all lines are drown, verlical sinchronization pulse (VSYNC) will be generated to tell to monitor that frame is over and next information should be outputed from the top of the screen. Frame rate must be greater than 60 Hz to prevent blinking. In standart VGA-mode each frame consist of 525 lines. 480 of them contain picture, and other contain top and bottom borders and blank lines for vertical sinchro (they have not color information). Each line is splitted at several parts: video information, left and right borders, horisontal blanking pulse. The lenght of line = 1s /60 frames / 525 lines = 31.75 us. Here is a picture dscribing data transfer to VGA: {{:osa:articles:vga_sync.png|}} ==== Picture generating ==== (not finished, see page in russian) === Synchro pulses === (not finished, see page in russian) ==== Scheme ==== {{:osa:articles:vga_terminal_scheme.png|}} ==== Test application ==== Here is a small test application for PIC16F88 {{:osa:articles:terminal_test.rar|Source code}} {{:osa:articles:vga_test_terminal_scheme.png|}} This aplication draws this picture: {{:osa:articles:vga_trm_test_screen.jpg?400|}}