CON 'Rev.1r: HyperRam VGA test with Evalboard Rev.A and Parallax HyperRam board 'MIT License 'Raymond Allen 2019 'Technology test: Using HyperRam as VGA screen buffer for Propeller 2 'This one is a single 640 pixel read, no tearing, perfect alignment. 'Now using COGATN to syncronize HyperRam with VGA 'Now using SmartPin to clock HyperRam 'VGA is on pins P0..P4 'PropCam base set to 16 'Changed from waitse1 to fixed waitx so data is in correct spot in memory. Adjust write latency to match. ' 'Propcam works between 250->360MHz system clock '****************************** '* VGA 640 x 480 x 8bpp-lut * '****************************** CON 'RJA: new for real P2 - you can use different xdiv and xmul to set clock frequency: /10*125 -> 250 MHz _XTALFREQ = 20_000_000 ' crystal frequency _XDIV = 20 ' crystal divider to give 1MHz _XMUL = 360 ' crystal / div * mul _XDIVP = 1 ' crystal / div * mul /divp to give _CLKFREQ (1,2,4..30) _XOSC = %10 'was %10 'OSC ' %00=OFF, %01=OSC, %10=15pF, %11=30pF _XSEL = %11 'XI+PLL ' %00=rcfast(20+MHz), %01=rcslow(~20KHz), %10=XI(5ms), %11=XI+PLL(10ms) _XPPPP = ((_XDIVP>>1) + 15) & $F ' 1->15, 2->0, 4->1, 6->2...30->14 _CLOCKFREQ = _XTALFREQ / _XDIV * _XMUL / _XDIVP ' internal clock frequency _SETFREQ = 1<<24 + (_XDIV-1)<<18 + (_XMUL-1)<<8 + _XPPPP<<4 + _XOSC<<2 ' %0000_000e_dddddd_mmmmmmmmmm_pppp_cc_00 ' setup oscillator _ENAFREQ = _SETFREQ + _XSEL ' %0000_000e_dddddd_mmmmmmmmmm_pppp_cc_ss ' enable oscillator CON intensity = 80 '0..128 fclk = _XMUL*1000000' mbecause xdivp =1'_CLOCKFREQ 'RJA: Adjusted for real P2 '80_000_000.0 fpix = 25_000_000.0 fset = (fpix / float(fclk) * 2.0) * float($4000_0000) vsync = 4 'vsync pin 'RJA: changed for real P2 BitmapData = $8000 CON 'PropCam assignments--rjo 'where to put propcam images on screen PropCam_screen_loc = BitmapData + 102_400 + 192 propcam_base = 16 prpcm_Data = 0 'input prpcm_HSync = 1 'input prpcm_SCL = 2 'output prpcm_SDA = 3 'i/o prpcm_VSync = 4 'output prpcm_MClk = 5 'output Left_prpcm_Data=prpcm_Data+propcam_base Left_prpcm_HSync = prpcm_HSync + propcam_base 'input '**Left and right PropCams share the following 4 pins: _prpcm_SCL = prpcm_SCL + propcam_base 'output _prpcm_SDA = prpcm_SDA + propcam_base 'i/o _prpcm_VSync = prpcm_VSync + propcam_base 'output _prpcm_VSync_period = fclk/4000000 _prpcm_MClk = prpcm_MClk + propcam_base'output Right_propcam_Data=Left_prpcm_Data + 6 Middle_propcam_Data=Left_prpcm_Data + 7 'PropCam Parameters _H_Blank=fclk/400_000 _CAPTURE_Height = 100 _CAPTURE_Width = 128 _EXP = 2046 'range 10-2046 _GAIN = 20 'range 0-31 _prpcam_frame_delay= fclk/1000 _prpcam_bit_delay=_XMUL/14 '_xmul/17 at 320mhz _prpcam_bit_delay2=_prpcam_bit_delay/2 _i2c_delay=_clockfreq/100000 CON 'Cog assignments PropCam_Left=4 VGA_Cog=0 DAT 'Start of HyperRAM test code orgh 0 org 0 '+-------[ Set Xtal ]----------------------------------------------------------+ ' RJA: New for real P2 hubset #0 ' set 20MHz+ mode hubset ##_SETFREQ ' setup oscillator waitx ##fclk/100 ' ~10ms hubset ##_ENAFREQ ' enable oscillator '+-----------------------------------------------------------------------------+ coginit #PropCam_Left,##@Propcam coginit #VGA_Cog,##@VGA_Driver 'this one has to be last as overwrites this cog endStart jmp #endStart '************************************************************************* '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 'fold vga DAT 'VGA_Driver 'vsync and hsync normally low orgh org 0 VGA_Driver 'drvl #Pin_Flag waitx ##50000000 ' rdfast #0,##$8000-$430 'load .bmp palette into lut mov x,#0 rep @.end,#$100 setbyte y,x,#0 setbyte y,x,#1 setbyte y,x,#2 shl y,#8 wrlut y,x add x,#1 .end ' wrlut ##$FF00,#255 rdfast ##640*480/64,##BitmapData 'set rdfast to wrap on one line of data continuosly fed by HyperRAM setxfrq ##round(fset) 'set transfer frequency to 25MHz 'the next 4 lines may be commented out to bypass level scaling setcy ##intensity << 24 'r set colorspace for rgb setci ##intensity << 16 'g setcq ##intensity << 08 'b setcmod #%01_0_000_0 'enable colorspace conversion 'RJA dacmodes changed for real P2 wrpin dacmode_s,#0 'enable dac modes in pins 0..3 wrpin dacmode_c,#1 wrpin dacmode_c,#2 wrpin dacmode_c,#3 setnib dira,#$f,#0 'RJA: New for real P2 ' ' ' Field loop ' field mov x,#33 'top blanks ' cogatn #(1<