Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CON
- _CLKMODE = RCSlow ' Start prop in RCSlow mode internal crystal
- PUB main
- clkset(%01101000, 12_000_000) ' Set internal oscillator to RCFast and set PLL to start
- waitcnt(cnt + 120_000) ' wait approx 10ms at 12mhz for PLL to 'warm up'
- clkset(%01101111, 80_000_000) ' 80MHz (5MHz PLLx16)
- coginit(COGID, @cogstart, @cogstart)
- ' dira[0]~~
- DAT
- org 0
- cogstart
- mov vcfg, ivcfg ' Sets up the parameters for video generation
- mov ctra, ictra ' internal PLL mode, PLLA = 16 * colorburst frequency
- mov frqa, ifrqa ' 2 * colorburst frequency
- mov dira, idira ' Sets pin directions
- '-----------------------------------------------------------------------------------------------
- ' MAIN LOOP
- '-----------------------------------------------------------------------------------------------
- mainloop
- mov numline, #9 ' 9 lines of vsync
- vsync0
- cmp numline, #6 wz ' lines 4,5,6 serration pulses
- if_nz cmp numline, #5 wz ' lines 1,2,3 / 7,8,9 equalizing pulses
- if_nz cmp numline, #4 wz '
- mov count, #2 ' 2 pulses per line
- :half
- if_nz mov VSCL, vscleqal ' equalizing pulse (short)
- if_z mov VSCL, vsclselo ' serration pulse (long)
- waitvid sync, #0 ' -40 IRE
- if_nz mov VSCL, vscleqhi ' equalizing pulse (long)
- if_z mov VSCL, vsclsync ' serration pulse (short)
- waitvid sync, blank ' 0 IRE
- djnz count, #:half
- djnz numline, #vsync0
- mov numline, #12 ' 12 blank lines
- blank0
- mov VSCL, vsclsync
- waitvid sync, #0 ' -40 IRE
- mov VSCL, vsclblnk
- waitvid sync, blank ' 0 IRE
- djnz numline, #blank0
- '-----------------------------------------------------------------------------------------------
- ' ACTIVE VIDEO
- '-----------------------------------------------------------------------------------------------
- mov numline, #241 ' 241 lines of active video
- active
- mov VSCL, vsclsync ' horizontal sync (0H) 4.7us
- waitvid sync, #0 ' -40 IRE
- mov VSCL, vscls2cb ' 5.3us 0H to burst
- waitvid sync, blank
- mov VSCL, vsclbrst ' 9 cycles of colorburst
- waitvid sync, burst
- mov VSCL, vsclbp ' backporch 9.2us OH to active video
- waitvid sync, blank
- '-----------------------------------------------------------------------------------------------
- ' VISIBLE SCAN LINE START
- '-----------------------------------------------------------------------------------------------
- mov VSCL, vsclactv ' PLLA per pixel, pixels per frame
- waitvid color, pixels
- waitvid color, pixels
- waitvid color, pixels
- waitvid color, pixels
- waitvid color, pixels
- waitvid color, pixels
- waitvid color, pixels
- waitvid color, pixels
- '-----------------------------------------------------------------------------------------------
- ' VISIBLE SCAN LINE END
- '-----------------------------------------------------------------------------------------------
- mov VSCL, vsclfp ' front porch 1.5us
- waitvid sync, blank
- djnz numline, #active
- jmp #mainloop
- '-----------------------------------------------------------------------------------------------
- ' END
- '-----------------------------------------------------------------------------------------------
- '-----------------------------------------------------------------------------------------------
- ' CONFIG DATA
- '-----------------------------------------------------------------------------------------------
- ivcfg long %0_11_0_0_1_000_00000000000_001_0_01110000 '
- ictra long %0_00001_110_00000000_000000_000_000000 ' NTSC (PLLDIV = VCO/2, PLL internal (video mode)
- ifrqa long $16E8_BA2F ' (7,159,090.9Hz/80MHz)<<32 NTSC demoboard & Hydra
- idira long $0000_7000 ' demoboard
- sync long $8A0200 ' %%0 = -40 IRE, %%1 = 0 IRE, %%2 = burst
- ' 0000 0000 1000 1010 0000 0010 0000 0000
- blank long %%1111_1111_1111_1111 ' 16 pixels color 1
- burst long %%2222_2222_2222_2222 ' 16 pixels color 1
- vscleqal long 1<<12+135 ' NTSC sync/2
- vsclsync long 1<<12+269 ' NTSC sync = 4.7us
- vsclblnk long 1<<12+3369 ' NTSC H-sync
- vsclselo long 1<<12+1551 ' NTSC H/2-sync
- vscleqhi long 1<<12+1685 ' NTSC H/2-sync/2
- vscls2cb long 1<<12+304-269 ' NTSC sync to colorburst
- vsclbrst long 16<<12+16*9 ' NTSC 16 PLLA per cycle, 9 cycles of colorburst
- vsclbp long 1<<12+(527-304-16*9)+213' NTSC back porch + overscan (213)
- vsclactv long 10<<12+10*32 ' NTSC 10 PLLA per pixel, 32 pixels per frame
- vsclfp long 1<<12+214+86 ' NTSC overscan (214) + front porch
- numline long $0
- count long $0
- color long %%1111_0000_1111_0000
- pixels long %10101010_10101010_10101010_10101010
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement