'--------------------------------------------------------------------------------
' s1d13517-vga-TCG057VG1AC-G00.txt
' Rev.1.0 		15th of February, 2011
' (C)SEIKO EPSON CORPORATION 2010. All rights reserved.
'--------------------------------------------------------------------------------
' Suffix "t" for register setting means decimal number.
' FPSHIFT = 25MHz, FRAME FREQ = 59.5Hz

verbose cmd:off out:on set:off
'-------------------- PLL -------------------------------------------------------
	x 04 17					' CLKI input clock 24MHz, 
						' PLL D-Div 1:24 24MHz->1MHz
	x 06 01					' VC[2:0] = 000 (PLL = 100MHz)
	x 08 01					' PLL clock 1/2 (50MHz)
	x 0C 31					' PLL N-Cnt 100MHz
	x 12 90					' SYSCLK = 1/2
	x 04 97					' PLL Enable
	x 0E 3F 				' SS Disable
	delay 1000000				' 1sec delay
	x 12 90					' PLL Clock sel
	x 68 01					' SYSCLK Enable
'-------------------- LCD controller setting ------------------------------------
	x 14 01					' 24bpp mode1(packed), 18bit
	x 16 4F					' HDISP = 640 ->(4Fh+1)x8
	x 18 4F					' HNDP  = 160 ->(4Fh+1)x2
	x 1A DF					' VDISP(Lower byte)  = 480 1DFh+1=480
	x 1C 01					' VDISP(Higher byte) = 480
	x 1E 10					' VNDP = 34 = (10h+1)x2
	x 20 1D					' HSW = 30 -> hsync polarity neg, width 1Dh+1
	x 22 00					' HPS = 0 -> hsync pulse start position, 0h
	x 24 02					' VSW = 3 -> vsync polarity neg, width 2h+1
	x 26 00					' VPS = 0 -> vsync pulse start position, 0h
	x 28 00					' PCLK -> PCLK polarity is falling edge
'-------------------- SDRAM setting ---------------------------------------------
	x 82 03					' SIZE 128Mbit
	x 8C 02					' refresh counter (Lower byte) 302h=770 
                                                ' i1/50MHz(SDCLK) x 770 = 15.4us)
	x 8E 03					' refresh counter (Higher byte)
	x 90 40					' write buffer size (VGA) 40h=64d 64x16kbytes=1Mbytes
                                                ' VGA 640 x 480 x 3bytes =921.6kbytes
'-------------------- CLK setting -----------------------------------------------
	x 68 E8					' Software reset ON except for SDRAM block
	x 68 00					' Software reset OFF
	x 68 01					' Sysem clock enable
'-------------------- SDRAM initialize ------------------------------------------
	x 84 82															' SDRAM init & auto refresh on
	delay 1000000				' 1sec delay
'-------------------- Panel size setting ----------------------------------------
	set $width_vga		640t		' VGA width
	set $height_vga		480t		' VGA height
	set $width_wvga		800t		' WVGA width
	set $height_wvga	480t		' WVGA height
	set $height_hvgah	240t		' halfVGA(horizontal) height
	set $widtht_hvgav	320t		' halfVGA(vertical) width
	set $width_qvgah	320t		' QVGA(horizontal) width
	set $height_qvgah	240t		' QVGA(horizontal) height
	set $width_qvgav	240t		' QVGA(vertical) width
	set $height_qvgav	320t		' QVGA(vertical) height
	set $width_qqvga	160t		' QQVGA width
	set $height_qqvga	120t		' QQVGA height
	
	set $main_fname0	"vgaimage0.bmp"	'Main window image file
	set $main_fname1	"vgaimage1.bmp"	'Main window image file
'-------------------- Window Size------------------------------------------------
	x 52 00					' BufferNo.:1
	x 5A 00					' Window X Start Position Register
	x 5C 00					' Window Y Start Position Register 0
	x 5E 00					' Window Y Start Position Register 1
	x 60 $width_vga/4-1			' Window X End Position Register
	x 62 ($height_vga-1)>>2			' Window Y End Position Register 0 = 480
	x 64 $height_vga-1			' Window Y End Position Register 1
	fload $main_fname0 reg 66 L1 EOF F=2 FN=3		 
'-------------------------------------------------------------------------------
	x 6A 00					' Non-Display Period Control / Status Register
'------------------- GPIO ------------------------------------------------------
	x 6C 00					' General Purpose Output Register 0
	x 6E 00					' General Purpose Output Register 1
'------------------- Display Mode setting --------------------------------------
	x 2A 01					' Main Buffer No.:1, Single Buffer, Display ON
	x 50 80					' Load Display Mode configuration
'-------------------------------------------------------------------------------
    print "hit any key! "
    input key
    print "\n"
'-------------------------------------------------------------------------------
	fload $main_fname1 reg 66 L1 EOF F=2 FN=3
	x 2A 01					' Main Buffer No.:1, Single Buffer, Display ON
	x 50 80					' Load Display Mode configuration
'-------------------------------------------------------------------------------
section end
