Barebone VGA driver

I used timings info from here:
http://www.javiervalcarce.eu/wiki/VGA_Video_Signal_Format_and_Timing_Specifications
http://tinyvga.com/vga-timing/640x480@60Hz
Tried on old crt and new lcd and it works, the LCD needed that I leave hpin low during V front porch (standard?)
I should update it so the code runs the same way visualy as: pixles,frontp,sync,backp. [DONE see second post]
This raw driver does not use waitvid, so you could add that later and get 8bit RrrGggBb
Display two colors on either half side of the screen
*** First version Deleted, get the one in second post instead ***
http://www.javiervalcarce.eu/wiki/VGA_Video_Signal_Format_and_Timing_Specifications
http://tinyvga.com/vga-timing/640x480@60Hz
Tried on old crt and new lcd and it works, the LCD needed that I leave hpin low during V front porch (standard?)
I should update it so the code runs the same way visualy as: pixles,frontp,sync,backp. [DONE see second post]
This raw driver does not use waitvid, so you could add that later and get 8bit RrrGggBb
Display two colors on either half side of the screen
*** First version Deleted, get the one in second post instead ***
Comments
It does not use separate v sync timer, instead it waits two horizontal lines for the v-sync low state.
Just to show what is involved with vga timing and learn from it (though using the whole 8bit for color in waitvid is now possible)
{640 by 480 raw vga driver V2} {P16=v_sync, P17 = h_sync, P19=color pin, P21 =color pin} CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 PUB vga_raw cognew(@asm_entry,0) 'launch assembly program in a COG DAT org 0 asm_entry mov dira,pinV 'set pins as output or dira,pinH or dira,pinB 'route P19 to Blue1 (example) or dira,pinG 'route P21 to Green1 (example) or outa,pinV 'set V-Sync High mov line,#481 'start up with a V-sync (why not) mov hsync,#9 'overhead to set up the first wait add hsync,cnt 'add current cnt jmp #set_hsync 'jump in to good start. pixels or outa,pinB 'set color pin high mov cnt,cnt 'move current cnt to shadow add cnt,pixlngt 'add pixel lenght to shadow cnt waitcnt cnt,pixlngt 'wait pixels andn outa,pinB 'change color pins or outa,pinG 'change color pins waitcnt cnt,#0 'wait pixels andn outa,pinG 'set color pin low, time left over is for H front porch set_hsync waitcnt hsync,hlow 'wait for hhigh to finish,then add hlow to hsync andn outa,pinH 'set h pin low add line,#1 waitcnt hsync,#152 'wait for hlow to finish,then add backporch to hsync or outa,pinH 'set h pin high waitcnt hsync,hhigh 'wait for back porch to finish, then add hhigh to hsync cmp line,#481 wc 'are we at line 1 to 480? if_c jmp #pixels 'if so keep showing pixels + hsync cmp line,#490 wz 'at line 490? if_z andn outa,pinV 'set V pin low at line 490 cmp line,#492 wz 'at line 492? if_z or outa,pinV 'set V pin high at line 492 cmp line,_525 wz 'at line 525? if_z mov line,#0 'ready to start at first line. jmp #set_hsync hhigh long 2086 ' 2086*12.5ns = 26.075 micro seconds [these values are 2 ticks too high so to align with hub reads] hlow long 306 ' 306 *12.5ns = 3.825 micro seconds [if no hub access, you should/could use 2085 and 305] ' take in account 152 *12.5 = 1.9uS back porch [all 3s total has to stay the same] pixlngt long 2024/2 ' half side one color. =25.3us /2 pinV long |<16 PinH long |<17 PinB long |<19 PinG Long |<21 _525 Long 525 line res 1 hsync res 1
Special version attached, Do Not Adjust Your Set everything is OK.
For fun/learning, I modified your "blue-green screen of death" to be a "blue-green-red screen of death" (like a tricolor flag) by defining pixlngt to be 2024/3 instead of 2024/2 and adding the code for red "bar" into your (visible) pixels code.
I'm new to this, but I think I read somewhere that some drivers take a "dot-clock" approach to the timing, whereas you've got fixed-length waits for the horizontal porches and synch (which seems fine and is ultimately probably pretty similar). The second link that you provided (which I came across before somewhere) shows the timing both in terms of clock time and dot-clocks (pixels), which is convenient (for comparison). Thanks for providing this instructive example and the links. --Jim